# Does Nginx have separate queuing mechanism for requests?

**URL:** <https://www.ruby-forum.com/t/does-nginx-have-separate-queuing-mechanism-for-requests/236776>\
**Category:** NGINX\
**Created:** [October 2, 2013, 4:04pm UTC](https://www.ruby-forum.com/t/does-nginx-have-separate-queuing-mechanism-for-requests/236776 "2013-10-02T16:04:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 2, 2013, 4:04pm UTC](https://www.ruby-forum.com/t/does-nginx-have-separate-queuing-mechanism-for-requests/236776/1 "2013-10-02T16:04:50Z")

</div>

Hello.

Consider the following situation: you are deploying application that can  
serve 1 req./sec. What would happen if I send 10 request in 1 second? I  
wrote simple app to test that:  
[GitHub - amezhenin/nginx\_slow\_upstream: This is small test for Nginx upstream mechanism.](https://github.com/amezhenin/nginx_slow_upstream) .  
This test shows that your requests will be served _in\_exact\_same\_order_  
they were sent.

For now, this looks like Nginx have some kind of queue for requests, but  
my  
colleague(administrator) sayd that there is no any queues in Nginx. So I  
wrote another question about epoll here:

> <https://stackoverflow.com/questions/19114001/does-epoll-preserve-the-order-in-which-fds-was-registered>

. From that discussion I figured that epoll does preserves the order of  
requests.

I have two questions:

1. Is there any mistakes in reasoning/code above?
2. Does Nginx have some sort of queue for requests on top of epoll? Or  
Nginx  
uses pure epoll functionality?

Thank you, and sorry for my English 🙂

Posted at Nginx Forum:

> **[Does Nginx have separate queuing mechanism for requests?](https://forum.nginx.org/read.php?2,243372,243372#msg-243372)**
>
> Hello. Consider the following situation: you are deploying application that can serve 1 req./sec. What would happen if I send 10 request in 1 second? I wrote simple app to test that: https://github.com/amezhenin/nginx\_slow\_upstream . This test shows...

---

<div class="post-metadata">

**Author:** ![amehzenin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@amehzenin](https://www.ruby-forum.com/u/amehzenin)\
**Post date:** [October 2, 2013, 5:41pm UTC](https://www.ruby-forum.com/t/does-nginx-have-separate-queuing-mechanism-for-requests/236776/2 "2013-10-02T17:41:55Z")

</div>

Hello!

On Wed, Oct 02, 2013 at 10:04:23AM -0400, amehzenin wrote:

> colleague(administrator) sayd that there is no any queues in Nginx. So I  
> wrote another question about epoll here:

> <https://stackoverflow.com/questions/19114001/does-epoll-preserve-the-order-in-which-fds-was-registered>

> . From that discussion I figured that epoll does preserves the order of  
> requests.
> 
> I have two questions:
> 
> 1. Is there any mistakes in reasoning/code above?
> 2. Does Nginx have some sort of queue for requests on top of epoll? Or Nginx  
> uses pure epoll functionality?

There is no queue in nginx, but there is queue in a listen socket  
of your backend app. It’s called “listen queue” or “backlog” and  
likely it’s what preserves a request order for you.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)

---

<div class="post-metadata">

**Author:** ![amehzenin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@amehzenin](https://www.ruby-forum.com/u/amehzenin)\
**Post date:** [October 3, 2013, 4:27pm UTC](https://www.ruby-forum.com/t/does-nginx-have-separate-queuing-mechanism-for-requests/236776/3 "2013-10-03T16:27:22Z")

</div>

## Maxim D. Wrote:

> nginx mailing list  
> removed\_email\_address@domain.invalid  
> [nginx Info Page](http://mailman.nginx.org/mailman/listinfo/nginx)

You meen application server has listen socket:

#include \<sys/types.h\>  
#include \<sys/socket.h\>

int listen(int sockfd, int backlog);

([listen(2): listen for connections on socket - Linux man page](http://linux.die.net/man/2/listen))

And backlog defines the length of this queue. Nginx pushes requests to  
app-server as they come and app-server take this requests from his own  
queue  
when he is ready to serve next request. Am I right?

Posted at Nginx Forum:

> **[Re: Does Nginx have separate queuing mechanism for requests?](https://forum.nginx.org/read.php?2,243372,243406#msg-243406)**
>
> Hello. Consider the following situation: you are deploying application that can serve 1 req./sec. What would happen if I send 10 request in 1 second? I wrote simple app to test that: https://github.com/amezhenin/nginx\_slow\_upstream . This test shows...

---

<div class="post-metadata">

**Author:** ![amehzenin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f6c823/32.png) [@amehzenin](https://www.ruby-forum.com/u/amehzenin)\
**Post date:** [October 3, 2013, 5:03pm UTC](https://www.ruby-forum.com/t/does-nginx-have-separate-queuing-mechanism-for-requests/236776/4 "2013-10-03T17:03:01Z")

</div>

Hello!

On Thu, Oct 03, 2013 at 10:26:33AM -0400, amehzenin wrote:

> ## Maxim D. Wrote:
> 
> > There is no queue in nginx, but there is queue in a listen socket  
> > of your backend app. It’s called “listen queue” or “backlog” and  
> > likely it’s what preserves a request order for you.

[…]

> app-server as they come and app-server take this requests from his own queue  
> when he is ready to serve next request. Am I right?

Yes.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)
