# Worker processes

**URL:** <https://www.ruby-forum.com/t/worker-processes/136899>\
**Category:** NGINX\
**Created:** [May 7, 2008, 7:37am UTC](https://www.ruby-forum.com/t/worker-processes/136899 "2008-05-07T07:37:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [May 7, 2008, 7:37am UTC](https://www.ruby-forum.com/t/worker-processes/136899/1 "2008-05-07T07:37:00Z")

</div>

Hello,

I am running Nginx as a reverse proxy with Mongrel. I haven’t been able  
to find a clear example of what to set the worker\_processes at. I’m  
running 10 mongrels and trying to find the sweet spot for Nginx.

If anyone has any insight in this, it would be appreciated.

Thanks,

- jason

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [May 7, 2008, 8:05am UTC](https://www.ruby-forum.com/t/worker-processes/136899/2 "2008-05-07T08:05:41Z")

</div>

1

Unless you are doing a LOT\* of static IO, you won’t need more than 1  
worker process.

Cheers

Dave

- to define a LOT, we serve 1.5m dynamic hits with 32 mongrels over 3  
machines using 1 nginx worker. Cpu usage, including compression, 5% max.

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [May 7, 2008, 8:23am UTC](https://www.ruby-forum.com/t/worker-processes/136899/3 "2008-05-07T08:23:54Z")

</div>

If you have multiple CPUs, you can also try setting the number of  
worker processes to the same number of CPU cores.

-Liang

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [May 7, 2008, 11:48am UTC](https://www.ruby-forum.com/t/worker-processes/136899/4 "2008-05-07T11:48:36Z")

</div>

On Tue, May 06, 2008 at 11:10:59PM -0700, kingler wrote:

> If you have multiple CPUs, you can also try setting the number of  
> worker processes to the same number of CPU cores.

It make sense only if nginx eats many CPU time for gzipping or SSL.  
Otherwise OS may schedule all workers on single CPU.

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [May 7, 2008, 5:05pm UTC](https://www.ruby-forum.com/t/worker-processes/136899/5 "2008-05-07T17:05:32Z")

</div>

Igor S. wrote:

> On Tue, May 06, 2008 at 11:10:59PM -0700, kingler wrote:
> 
> > If you have multiple CPUs, you can also try setting the number of  
> > worker processes to the same number of CPU cores.
> 
> It make sense only if nginx eats many CPU time for gzipping or SSL.  
> Otherwise OS may schedule all workers on single CPU.

So real quick I have to say, after using all the ‘big’ http servers,  
Nginx is my favorite. Not just for the speed, but the configuration is  
so much easier, so thanks! This is my default HTTP server now. 🙂

I’m running my production server on 2 x 4-core Xeons. I have my conf  
setup with SSL, gzip. When hitting the server, the load is minimal.

I heard in this thread that 1 worker is enough. But if I needed more,  
then I’d be more than happy to do that. I did play around with the  
settings and when I cranked up the worker\_processes to 10, it seemed  
like my pages took a little bit more time - there was a lot of browser  
activity it was showing me at the bottom of my window. However, when I  
dropped the worker process down to 2 (where it’s at now), everything  
seemed snappier.

So is the worker process the one thread thread that listens on port 80?  
Or is it a multithreaded process that listens and then uses the worker  
connects (which are threads?) to listen to incoming requests? Or am I  
completely wrong all together.

Thanks for everyone’s replies!

- jason

---

<div class="post-metadata">

**Author:** ![leveille](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@leveille](https://www.ruby-forum.com/u/leveille)\
**Post date:** [May 7, 2008, 9:30pm UTC](https://www.ruby-forum.com/t/worker-processes/136899/6 "2008-05-07T21:30:36Z")

</div>

On Wed, May 07, 2008 at 05:05:32PM +0200, Jason L. wrote:

> Nginx is my favorite. Not just for the speed, but the configuration is  
> dropped the worker process down to 2 (where it’s at now), everything  
> seemed snappier.
> 
> So is the worker process the one thread thread that listens on port 80?  
> Or is it a multithreaded process that listens and then uses the worker  
> connects (which are threads?) to listen to incoming requests? Or am I  
> completely wrong all together.

A worker process is one-threaded process.
