Keep Redis running 24/7 with Service Protector

How to Keep Redis Running 24/7 with Service Protector

Automatically restart the Redis Windows Service if it crashes or is accidentally shut down. Ensure that your in-memory database is always available to serve your applications.

Redis is an open-source in-memory data structure store supporting common data structures. The Microsoft Open Technologies port can be installed as a Windows Service for 24x7 operation. Here it is in services.msc:

To protect the Redis service with Service Protector 5.0 and later:

  1. Download and install Service Protector, if necessary.

  2. Start Service Protector.

  3. Select Protector > Add to open the Add Protector window:

    Add Protector

  4. On the General tab, select the Redis service in the Service to protect dropdown. You will notice a green circle on the left if the service is already running, as pictured below.

    Redis Windows Service: General Tab

  5. If you are interested in monitoring Redis and detecting when it stops responding to network requests on its TCP/IP port, click over to the Monitor tab. We'll set up a failure detection command to tell Service Protector when Redis is not accepting requests.

    1. Check the Whenever it fails a "sanity check" box and click the "..." button to open the Configure Sanity Check window.

    2. Enter the full path to our ConnectToSocketSanityCheck.exe utility, which can be found in the "SanityCheck" folder inside your AlwaysUp installation directory, followed by "localhost" and your Redis port number. If you installed AlwaysUp in its regular location and stuck with the default Redis port number (6379), the full command line to enter will likely be:

      "C:\Program Files (x86)\AlwaysUp\SanityCheck\ConnectToSocketSanityCheck.exe" localhost 6379
      Be sure to quote your exe path if it contains a space!

    3. Change the Every controls to 5 minutes or set it to any value that you find appropriate. More time means less frequent checks (and less poking of the server), but it also means that errors can linger undetected for a longer period.

    4. Press the OK button to save your sanity check settings.

    Redis Windows Service: Monitor Tab

  6. Click the Save >> button. In a couple of seconds, an entry for Redis will show up in the Service Protector window. Protection should have started and the shield icon should be green to indicate that Redis is being watched by Service Protector. Your Redis service is now safe from accidental shutdowns!

    Redis Windows Service: Protector Created

  7. Note that you can use Service Protector's icons to gain some insight into the Redis service and how it is being protected.

    Click on the green circle in the "Service State" column to see key information on the Redis service itself:

    Redis Windows Service Information

    Or click on the green shield in the "Protection" column to reveal a popup showing when protection started:

    Redis Windows Service Protector Details

  8. That's it! Next time your computer boots, Redis will start as normal and Service Protector will begin monitoring the service to promptly restart it if it fails or stops for any reason.

    We encourage you to edit Redis in Service Protector and check out the many other settings that may be appropriate for your environment. For example, send an email when the service fails, cycle Redis during the early-morning hours to keep performance snappy, restart the Redis service if it gets stuck starting, and much more.

Trouble protecting the Redis Windows Service?