Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I plan on using nginx to host much of my static content with some minimal php. I'm going to have 2 servers for nginx, but that may be too much hardware for what I need. I'm thinking about dividing them into a total of 4 nginx virtual machines (2 per box). This would allow me to more flexibly divide the resources between nginx and the other parts of the site (which are apache).

Most of the cpu/ram would be used to host the static files and execute system calls from php.

We would use vmware esx to make the virtual machines.

Would we take a major performance hit by running nginx on the VMs as opposed to running it natively on the hardware?

share|improve this question
up vote 1 down vote accepted

"Would we take a major performance hit by running nginx on the VMs as opposed to running it natively on the hardware?"

It depends on the underlying hardware and how you're allocating it. Are you going to run several other virtual machines on the same hosts? How many virtual CPU's are you going to allocate versus logical CPU's available?

There is a CPU toll when it comes to virtualisation, but it's extremely little. It can be mitigated by "pinning" the virtual CPU's to logical CPU's with careful planning.

share|improve this answer
The underlying hardware is a quad core cpu per box. Each VM would probably have 2 cpus (or I could make it 1 cpu per VM if that would be better for performance). – matzahboy Jul 26 '11 at 14:25

All of our virtual servers that host websites come with nginx by standard in my company. The overhead of running nginx is tiny for memory and CPU when compared to the possible huge amounts Apache2 can use.

These days I never set-up a web environment without nginx serving static content - unless of course I put Varnish there instead and cache away.

Edit: to give you more info our heaviest loaded VMs (4xCPU 8GB RAM) app servers with nginx having 8 worker processes and 1024 worker connections RP to Apache2, nginx uses 6MB of RAM at peak.

share|improve this answer
My question is not about nginx vs. apache. It is about using a VM for nginx vs. running nginx natively on the hardware. – matzahboy Jul 27 '11 at 15:36
That is why I modified by comment, I've not seen nginx being CPU intensive at all, it's mostly using a tiny amount of memory. Of course this really depends on what you're using nginx for. In my example I use it to serve static content and reverse-proxy dynamic content back for Apache2, if you're using it with fcgi then maybe it will be more CPU intensive. – Kura Jul 27 '11 at 15:56
I'm using it for static content and fcgi. The php (from fcgi) makes some cpu-intensive exec commands, but the php itself is cheap. – matzahboy Jul 27 '11 at 15:58
I would say unless there is a good reason for you to separate the system out in to virtual machines then don't bother. But that's my personal opinion. – Kura Jul 27 '11 at 16:22

Your Answer


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.