Nginx & MySQL - resource question

Setting up nginx for the first time, I have the Linode 360 package (360MB ram), planning on running Wordpress blogs.

What would be the optimal configuration settings for nginx and mysql?

How much RAM / worker-threads should I assign?

What's a good keepalive_timeout?

10 Replies

anybody? please? i'm quite interested in this myself…

nginx uses almost no RAM, so you might as well use four worker threads. You can also set a high keepalive for the same reason, but make sure you have a large limit on max connections and your file descriptor limit is high enough too.

www-data  5579  0.0  0.2   5016  1748 ?        S    Apr17   5:33 nginx: worker process
www-data  5580  0.0  0.2   5024  1768 ?        S    Apr17   5:23 nginx: worker process
www-data  5581  0.0  0.2   5008  1772 ?        S    Apr17   5:23 nginx: worker process
www-data  5582  0.0  0.2   5028  1768 ?        S    Apr17   5:44 nginx: worker process
root     24332  0.0  0.1   4992  1412 ?        Ss   Mar19   0:00 nginx: master process /usr/sbin/nginx

and the relevant parts from my nginx.conf:

events {
        worker_connections  512;
http {
        keepalive_timeout 60 55; 

Beautiful poem on your website, contraculto (sorry – not to appear dodgy ;) )

Did you write it ?

nope, not even close :P

that's the bene gesserit litany against fear, from frank herbert's dune series. :)

argh, it's been too long :)

If you're running PHP then nginx alone is not good enough, you must pass the request through to something like Apache (which you probably don't want because you're limited in RAM) or some PHP FastCGI backend.

For a FastCGI backend, I recommend one of two options:

1. If you're compiling PHP on your own then go for PHP-FPM ( Although I haven't used it myself (since I prefer to use YUM RPMs to keep my PHP updated), I've read a lot of good things about it.

2. If you (like me) install PHP using ready-to-go RPMs for your distro, then use the spawn-fcgi released by LightTPD ( NOTE: You do not need to be running LightTPD to be able to run their spawn-fcgi.

daskalou, I'm running PHP-FPM.

How much RAM should I allocate to PHP if I only have 360mb altogether?

I'm running WordPress-MU on nginx, MySQL and PHP.

I'm not sure how much RAM will be consumed by WordPress MU per FCGI instance, but we're using the Symfony framework ( - which is notorious for its bloat - and a PHP opcode cacher (XCache, APC etc.) and our FCGI processes each consume up to 40MB - 60MB of RAM (with about 1/4 - 1/3 in shared memory).

I would assume WordPress MU has been refined enough to be much less bloated than Symfony (although I could be wrong), so would probably consume a lot less RAM.

RAM usage per FCGI process would also depend on the maximum requests allowed per process (the lower the value, the less chance of memory creeping up).

How many FCGI child processes do you have running at any one time? With 360MB of RAM in total, you should probably set this low as well.

it's nginx have options to limix connection per ip ?


it's nginx have options to limix connection per ip ?

Here you go:


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct