Snapchat / KeyDB

A Multithreaded Fork of Redis
https://keydb.dev
BSD 3-Clause "New" or "Revised" License
11.5k stars 578 forks source link

Add Windows Support #87

Open ashkank83 opened 5 years ago

ashkank83 commented 5 years ago

Hi, I know Redis cannot be deployed on Windows servers and I understand that KeyDB uses Redis, however just wondering if MS windows compatible builds are in the roadmap for you guys at all? Or are there any ports of keydb currently available for running on windows servers? Thx

JohnSully commented 5 years ago

One day I would like to support Windows but it won’t be for a very long time. We rely heavily on the fork() system call which is not available on Windows and refactoring that out is a very large amount of work. There are no ports running on Windows that I know of.

JohnSully commented 5 years ago

The best way to work around this if you are primarily a windows shop is to run Linux+KeyDB in a HyperV VM. We also have an AMI coming soon for AWS with everything preconfigured.

softeering commented 5 years ago

@ashkank83 FYI, I usually install WSL on Windows and run stuff such as Redis this way. And also, Docker container is available on Windows

JohnSully commented 5 years ago

Progress is actually being made here. I’ve got initial support for forkless background saving working which is the primary blocker. There is still a lot of work to bring up Windows so I don’t want to promise any sort of timeline, but I will reopen this bug to track it.

Qix- commented 5 years ago

Just want to provide a bit of a resistance to this: please don't allow any of the changes necessary to make Windows work negatively impact the codebase as-is. I feel like Windows servers for very inherently linux-oriented things are an antipattern and with WSL becoming mainstream and supported by Microsoft ports like these shouldn't be necessary anymore.

If it's going to make the code more complicated or incur even a single additional clock cycle of latency on the Linux side then it's not worth it IMO.

JohnSully commented 5 years ago

Hi @Qix-,

Forkless background saving is really about Linux performance first and foremost. The issue with using fork() for snapshotting is write amplification, if you modify even one byte on a page all 4K needs to be duplicated.

The other issue is that fork() time is related to the total dataset size. In contrast forkless background save has the same cost if your key is 1 byte or 500MB. This will become important as value sizes increase.

Forkless background save will be both faster and use less memory. So its a huge win for Linux.

aria-golliver commented 4 years ago

It took me only a few minutes to get KeyDB built and running with cygwin. I haven't tested much, but starting the server & setting a few values over telnet worked a lot more smoothly that I thought it was going to.

Had to do something really sketchy with SO_REUSEPORT, not quite sure what æffect deleting anetSetReusePort will have.

JohnSully commented 4 years ago

SO_REUSEPORT use to be mandatory for multi-threading to work at all. In more recent builds if you remove this flag then we will only accept new connections on the main thread but should still be able to distribute them across threads.

yusufozturk commented 3 years ago

SO_REUSEPORT and SO_REUSEADDR is supported on Windows as well. Here is the screenshot on Windows:

image

I was able to listen same port from multiple threads.

Looking forward to see Windows support of KeyDB in the future 👍

wanstr commented 2 years ago

I'm trying to install keydb in WSL (Ubuntu 20.04) and I got this error when it reached the keydb-server step: "System has not been booted with systemd as init system (PID 1). Can't operate." I know WSL doesn't support systemd and has its own way of running a service. I'm also aware of hacks that can sort of make systemd availble, but they seem to have their own drawbacks. My question is, is that the way to go just to get keydb installed? Or am I missing something?

Kailash-Ramco commented 2 years ago

Hi Team,

I am also trying to install key-db using WSL on windows server, but i get the following error (same as @wanstr but i don't get through the installation)

Error

image

Windows Server Version

image

Commands used for installation

$ echo "deb https://download.keydb.dev/open-source-dist $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/keydb.list $ sudo wget -O /etc/apt/trusted.gpg.d/keydb.gpg https://download.keydb.dev/open-source-dist/keyring.gpg $ sudo apt update $ sudo apt install keydb

wanstr commented 2 years ago

@Kailash-Ramco If you really want to use it with WSL now, you can do it with genie. That's not a perfect solution though, hence my original question.

edge-rps commented 1 year ago

If anyone needs KeyDB to run on windows for development purposes, consider using a Docker container that auto starts in the background.

vzvedran commented 1 year ago

@aria-golliver Could you share your cygwin setup? I'm also trying to compile it, and having some issues I believe with malloc

In file included from ae.cpp:105:
ae_select.c: In function ‘int aeApiCreate(aeEventLoop*)’:
ae_select.c:43:32: error: invalid conversion from ‘void*’ to ‘aeApiState*’ [-fpermissive]
   43 |     aeApiState *state = zmalloc(sizeof(aeApiState), MALLOC_LOCAL);
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                |
      |                                void*
ae_select.c: In function ‘int aeApiResize(aeEventLoop*, int)’:
ae_select.c:52:37: warning: unused parameter ‘eventLoop’ [-Wunused-parameter]
   52 | static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
      |                        ~~~~~~~~~~~~~^~~~~~~~~
ae_select.c: In function ‘int aeApiAddEvent(aeEventLoop*, int, int)’:
ae_select.c:63:36: error: invalid conversion from ‘void*’ to ‘aeApiState*’ [-fpermissive]
   63 |     aeApiState *state = eventLoop->apidata;
      |                         ~~~~~~~~~~~^~~~~~~
      |                                    |
      |                                    void*
ae_select.c: In function ‘void aeApiDelEvent(aeEventLoop*, int, int)’:
ae_select.c:71:36: error: invalid conversion from ‘void*’ to ‘aeApiState*’ [-fpermissive]
   71 |     aeApiState *state = eventLoop->apidata;
      |                         ~~~~~~~~~~~^~~~~~~
      |                                    |
      |                                    void*
ae_select.c: In function ‘int aeApiPoll(aeEventLoop*, timeval*)’:
ae_select.c:78:36: error: invalid conversion from ‘void*’ to ‘aeApiState*’ [-fpermissive]
   78 |     aeApiState *state = eventLoop->apidata;
      |                         ~~~~~~~~~~~^~~~~~~
      |                                    |
      |                                    void*
ae_select.c: In function ‘char* aeApiName()’:
ae_select.c:105:12: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  105 |     return "select";
      |            ^~~~~~~~
ilovefreesw commented 3 months ago

Might be helpful: https://stackoverflow.com/a/76290679/21906181

A5M1 commented 2 months ago

any updates here ?