Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a VPS with 1 CPU Core, when I was searching around for some nice documentation on configuring nginx and php5-fpm I constantly came across stuff like "I have a dual core CPU so I will limit this to 2 processes.."

Now my question is, as I have 1 core, is it a good idea to limit nginx ( as well as php5-fpm ) to 1 process? If I am correct this shouldn't be a problem for the multithreaded nginx architecture?

Currently the server seems to be running fine but the load is very low, when using AB from my home connection I get a timeout after 499 connections -- but I'm not entirely sure why it times out ( my whole system froze ).

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The problem with reading stuff on the Internet is that it's usually got no useful rationale (if you're lucky), doesn't apply to your situation, or is downright plain-and-simple wrong (by far the most common).

If your request processing is entirely CPU-bound within the fpm worker, then yes, having any more than one process per core isn't going to improve throughput. However, that is an incredibly rare scenario -- typically your PHP script is hitting the DB, or reading stuff off the filesystem, or making external connections to fetch other data, or whatever. All of that is CPU time that, if you've only got one fpm worker per core, is going to be wasted.

What is the correct configuration for your environment is a mix of "know your app" and experimentation. I'd try with probably two fpm workers on a single core, and see what happens under load (real load, not ab load). If the CPU is completely pegged, then you're probably doing more CPU work than can be handled and you should dial it back a bit (or just get more CPU). If you're maxing out on throughput but the CPU is still fairly idle, then you can ramp up the number of workers until the CPU is close to maxed out.

Of course, this assumes that there isn't a lot of other stuff going on on the machine that needs CPU time itself. You've got to give nginx some CPU time, and if you've got a database or anything on there it'll need a look-in too, but happily enough that tends to sort itself out as you watch the CPU go up with worker count.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.