EGOPOLY

Topics include: programming, Apple, Unix, gadgets, large-scale web sites and other nerdy stuff.

memcached on Mac OS 10.4 slowness fix

2006-05-15 19:00:38

We use memcached at work to vastly reduce load on the application servers and on mysql. The problem is that on Mac OS 10.4 Tiger it was so slow as to be worse than not using it: one query would take 5 seconds, instead of like 5 milliseconds on Linux. It was never a huge deal, because we deploy on Linux, and there are lots of Linux machines around the office. But it made it hard to run a self-contained deployment environment on the developer's Mac.

My friend Derek found this article, which details the fix. I tested it, and it works for me. Super short summary:

Edit memcached.c and add (anywhere above line 105, which reads #ifdef TCP_NOPUSH) the line:

#undef TCP_NOPUSH

Then

make install setenv EVENT_NOKQUEUE 1 /usr/local/bin/memcached -m 128 -p 11211