KeyDB icon indicating copy to clipboard operation
KeyDB copied to clipboard

Add Windows Support

Open ashkank83 opened this issue 5 years ago • 16 comments

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

ashkank83 avatar Oct 02 '19 13:10 ashkank83

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 avatar Oct 02 '19 15:10 JohnSully

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.

JohnSully avatar Oct 02 '19 15:10 JohnSully

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

softeering avatar Oct 08 '19 10:10 softeering

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.

JohnSully avatar Oct 23 '19 15:10 JohnSully

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.

Qix- avatar Oct 25 '19 09:10 Qix-

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.

JohnSully avatar Oct 25 '19 19:10 JohnSully

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.

aria-golliver avatar Apr 15 '20 23:04 aria-golliver

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.

JohnSully avatar Apr 15 '20 23:04 JohnSully

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 👍

yusufozturk avatar Oct 20 '21 09:10 yusufozturk

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?

wanstr avatar Mar 04 '22 04:03 wanstr

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

Kailash-Ramco avatar Mar 15 '22 04:03 Kailash-Ramco

@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.

wanstr avatar Mar 15 '22 05:03 wanstr

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

edge-rps avatar Dec 03 '22 00:12 edge-rps

@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";
      |            ^~~~~~~~

vzvedran avatar Mar 27 '23 11:03 vzvedran

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

ilovefreesw avatar Jul 22 '24 11:07 ilovefreesw