# Nginx support multithread

**URL:** <https://www.ruby-forum.com/t/nginx-support-multithread/213214>\
**Category:** NGINX\
**Created:** [October 26, 2011, 4:50pm UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214 "2011-10-26T16:50:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [October 26, 2011, 4:50pm UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/1 "2011-10-26T16:50:17Z")

</div>

I saw multithread support in the source code, but why multithread is not  
supported in current version? And is any one know whether and when  
multithread will be supported?

Posted at Nginx Forum:

> **[nginx support multithread](https://forum.nginx.org/read.php?2,217370,217370#msg-217370)**
>
> I saw multithread support in the source code, but why multithread is not supported in current version? And is any one know whether and when multithread will be supported?

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 26, 2011, 4:58pm UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/2 "2011-10-26T16:58:20Z")

</div>

On Wed, Oct 26, 2011 at 10:49:47AM -0400, wdmchaft wrote:

> I saw multithread support in the source code, but why multithread is not  
> supported in current version?

Because threads support is broken.

> And is any one know whether and when  
> multithread will be supported?

Probably, in 2.0.

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 26, 2011, 11:44pm UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/3 "2011-10-26T23:44:11Z")

</div>

On Wed, Oct 26, 2011 at 10:57 AM, Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > And is any one know whether and when  
> > multithread will be supported?
> 
> Probably, in 2.0.

What would be the usage of multi-threads?

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 27, 2011, 3:43am UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/4 "2011-10-27T03:43:43Z")

</div>

Multiple worker threads against worker process?

2011/10/27 Brian A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 27, 2011, 1:08am UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/5 "2011-10-27T01:08:40Z")

</div>

As far as I understand, nginx is event driven and support a bunch of  
different schedule strategies at kernel level.. that should be  
enough.. but in any case.. you can always run N nginx bounded to  
different cpu’s in case you really needed

Regards

M

On Wed, Oct 26, 2011 at 7:43 PM, Brian A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Nunca hubo un amigo que hiciese un favor a un enano, ni un enemigo que  
le hiciese un mal, que no se viese recompensado por entero.

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 27, 2011, 9:41am UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/6 "2011-10-27T09:41:47Z")

</div>

On Thu, Oct 27, 2011 at 5:43 AM, Brian A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Wed, Oct 26, 2011 at 10:57 AM, Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > And is any one know whether and when  
> > > multithread will be supported?
> > 
> > Probably, in 2.0.
> 
> What would be the usage of multi-threads?

Mostly for (blocking) disk I/O and other syscalls that have to block  
the main thread of an nginx worker 🙂

Regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 27, 2011, 1:07pm UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/7 "2011-10-27T13:07:24Z")

</div>

On Oct 27, 2011, at 3:41 AM, agentzh wrote:

> > What would be the usage of multi-threads?
> 
> Mostly for (blocking) disk I/O and other syscalls that have to block  
> the main thread of an nginx worker 🙂

True. I’ve seen some systems where the overhead of the thread/queue  
management was more than just letting the system call block the main  
thread. We generally run 2 nginx procs per CPU core.

I just worry about bloat. There is a reason nginx’s market share is  
rising and Apache’s is falling.

–Brian

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 27, 2011, 3:23pm UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/8 "2011-10-27T15:23:29Z")

</div>

On Thu, Oct 27, 2011 at 03:41:24PM +0800, agentzh wrote:

> Mostly for (blocking) disk I/O and other syscalls that have to block  
> the main thread of an nginx worker 🙂

Yes. Primarily auxiliary threads to offload openning of not recently  
used files, disk i/o, etc. Second goal is to make nginx internals being  
thread-safe to allow experiments with different processing models.

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![wdmchaft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19adc/32.png) [@wdmchaft](https://www.ruby-forum.com/u/wdmchaft)\
**Post date:** [October 28, 2011, 8:26am UTC](https://www.ruby-forum.com/t/nginx-support-multithread/213214/9 "2011-10-28T08:26:36Z")

</div>

On Thu, Oct 27, 2011 at 07:06:29AM -0400, Brian A. wrote:

> True. I’ve seen some systems where the overhead of the thread/queue management  
> was more than just letting the system call block the main thread.  
> Could you eleborate this case ?  
> For example, on non-SSD disk, I/O blocking may take several  
> milliseconds,  
> while very expensive fork() syscall takes about 100-200 microseconds  
> on modern CPU.

–  
Igor S.
