Memcached error when running siege

Posted July 28, 2013 7k views
Hello: I am kind of new to server setups. I installed Nginx + NGX Pagespeed + PHP FPM + APC + MemCached on Ubuntu 12.04 and topped all of this with Joomla 3.1 All works well except when I try to run siege for load testing. When I use the -b parameter with siege (benchmarking), I start getting a 502 error immediately. Even if I bring the concurrent connections down to 2, I still get the error. The site goes down and even in a browser, I get a 502 error. With some research, I think the issue is with the persistent connections in Memcached however I have no clue on how and where to tweak the configuration. In fact, I do not know how to proceed :-( When I run siege, without the -b switch, and even with 50 users - all works fine. Will appreciate some guidance preferably if you can point me to some links / tutorials. Thanks and regards, Mangesh

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers
Your droplet could be running out of memory, try adding some swap:
by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
Cool :) Will check and revert... Thanks. Appreciate it.
Well, I added Swap and the 502s have gone :)

But now Siege reports a different error:

siege aborted due to excessive socket failure

On doing some research, found an article on Stack Overflow which states the following:

The problem may be that you run out of ephemeral ports. To remedy that, either expand the number of ports to use, or reduce the duration that ports stay in TIME_WAIT, or both.

Expand the usable ports:

Check your current setting:

$ sudo sysctl net.inet.ip.portrange.hifirst

net.inet.ip.portrange.hifirst: 49152

Set it lower to expand your window:

$ sudo sysctl -w net.inet.ip.portrange.hifirst=32768

net.inet.ip.portrange.hifirst: 49152 -> 32768

(hilast should already be at the max, 65536)

Reduce the maximum segment lifetime

$ sudo sysctl -w net.inet.tcp.msl=1000

net.inet.tcp.msl: 15000 -> 1000

Unfortunately, when I try the first command, I get the following error:

error: "net.inet.ip.portrange.hifirst" is an unknown key

Any clue where am I going wrong?

Thanks and regards,
Issue resolved. It was actually with PHP FPM listening on Unix socket. Changed it back to TCP.