Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /share/CACHEDEV1_DATA/Web/www/libraries/UBBcode/text_parser.class.php on line 228
Memcached: running multiple services on Windows

Comments Blog About Development Research Sites

Memcached
Running multiple services on Windows

Mar 17, 2012
About four years ago, I wrote about memcache. In the particular issue we were facing, it turned out to be a perfect solution. Since then I have encountered it on a few more occasions, though its use remained sparse.

For a current project, I was once again looking into memcached. This time, there is a search engine which takes into account a great many factors (much like internet search engines) to combine and rank a list of targets. Normally this would be quite fast, especially when the search was limited to a specific region or target name. However, with the advent of a new app and its ability to search by radius, certain queries would take quite long to parse. Memcached could be a good solution here, but since there are multiple (similar) sites with slightly different databases, we would prefer multiple instances of the memcache daemon to run in parralel.

First thing, you will want to download memcached. Do not install it as a service just yet; if we want to run multiple services, we need to do that manually.

Start by opening a command line and navigate to where you extracted memcached. Now we use the "sc create" command to create multiple instances:

Code (php) (nieuw venster):
1
2
3
D:\>sc create "Memcached11211" binPath= "D:\Servers\Memcached\memcached.exe -d runservice -p 11211" DisplayName= "Memcached11211"

D:\>sc create "Memcached11212" binPath= "D:\Servers\Memcached\memcached.exe -d runservice -p 11212" DisplayName= "Memcached11212"


This creates 2 instances, once on port 11211 (the default) and once on port 11212. We can now simply start those with "sc start Memcached11211" and "sc start Memcached11212" respectively. Note how the name and description both indicate which port we run on: this is the port argument (-p [port]) added to the command. You cannot run two memcached instances on the same network interface, on the same port.

FragFrog out!

Mar 30, 2012

I've taken a look at this, specially the source code for Memcache, it turns out, its quite easy to add set memory groups, for example, you can limit how much each memcache uses, I've tested it running 3, with a limit to 64mbits each, and managed to have it stay inside the ram, so it doesn't pagefile anything. Thus making it a lot quicker. Maybe you should take a look into this ;)

Jan 12, 2013 Deccan Rock

Dear FragFrog, Your instructions are perfect to start multiple instances on a windows box. I successfully created 4 instances of the service on 64 bit build of BeITMemcached.
One can also use "net start <service name>" command as an alternate to "sc start.."
Thanks

New comment

Your name:
Comment: