NGINX using 100% of the server CPU when testing with

I’m facing an issue here and after four days of looking around I decided to ask for some help here, after all a million heads can think a lot better than one.

I have a Ubuntu 14.04 server setup with NGINX, HHVM, PHP5-FPM (as a backup), Percona MySQL, Memcached (which will be replaced by Redis). I have fastcgi_cache setup for WordPress and object caching done over memcached. All cool and dandy in theory, but not in practice.

This is a RamNode OpenVZ SSD VPS with 2GB of RAM and an Intel Xeon E5 with two cores for my VPS.

Running on it the server is getting absolutely murdered by the two NGINX worker processes, which each one using 100% CPU according to top and htop. I usually run with the following pattern:

--pattern 999-1000:60

That makes makes CPU go to the roof and according to this is the result of that:


Obviously that isn’t good. RAM usage stay under 250MB all the time and it seems that all those requests from are hitting the cache, as seen here: - HIT [23/Nov/2014:19:06:32 -0200] “GET / HTTP/1.1” 200 7632 “-” “; 20bed746e60d4e53401c0c04d245c4eb@

Notice the HIT at the start. I set a new log format and added $upstream_cache_status to it.

A similar setup on the same machine works just fine with, so there is definitely something wrong with my NGINX setup and it seems related to fastcgi_cache. I have the same results every time, even with just PHP5-FPM with Zend.

Does anyone have a clue about what is happening? My configuration files look like this:

Thanks in advance.


Have you tweaked sysctl?


Also, if possible try to run same test on exactly same setup on DigitalOcean or Linode $20 plan. (both charge you by hour so you won’t end up paying for complete month)

Thank you for the suggestions :slight_smile:

Haven’t tweaked it yet, not sure if it’s possible on OpenVZ but I will take a look (EDIT: permission denied when running sysctl -p as root) . As for Linode they aren’t accepting my credit card for some reason, which is why I went with RamNode.

I’m sure there is something wrong with my NGINX setup because a similar setup run without any issues on the same server, and RamNode is known for being crazy fast (faster than Linode on some benchmarks).

Replicated this setup on another server, this time with a quad-core CPU and using KVM. Same issue, all cores end up using 100% of the server CPU.

Tested it with HTTP instead of HTTPS and while it did reach 100% of CPU usage from time to time, the average load was 50% and the test was a lot better:

  • 33,086 HITS WITH 29 ERRORS & 2,344 TIMEOUTS

Why would SSL perform so badly? I generated the key with 4096 instead of 2048, but I don’t believe that would affect CPU usage this much.

Sorry. I missed SSL part.

Try removing lines 10-14 from

Also try our SSL config

If possible please share results of above 2 tests. Thanks.

@rahul286 Turns out it was the key in the end, as 4096 was using too many CPU cycles. I will keep trying to optimize the settings as the CPU usage is still too high for my liking, but the actual problem here was my key.

Thanks for details. :smile:

I think blitz like tool may not make use of SSL session cache very well. Difference between SSL v/s non-SSL could be because of SSL session cache.

@rahul286 I do believe that is true. With the new server everything is running smooth with my new settings, but lets see once real traffic gets in how things will go. hit the server with only one IP address, might as well be an issue as well. Do you have other benchmarks tools to recommend?

@julianfernandes I really don’t get into benchmarks as they are hard to trust. I try to speed up a single request in debug mode and go after each error/warning/notice I see.

This is our checklist -

Still and other has chrome extensions to emulate transaction processing. You may try them if SSL is used for some e-commerce section.

@rahul286 Gonna make sure I read that, thanks for all the help =)