Does Nginx have separate queuing mechanism for requests?
Asked Answered
A

1

13

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 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: Does epoll preserve the order in which fd's 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 :)

Alicaalicante answered 2/10, 2013 at 14:40 Comment(0)
A
6

Nginx doesn't have it own queue, instead it pushes all requests to the application server, which have a listen socket:

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

int listen(int sockfd, int backlog);

(http://linux.die.net/man/2/listen)

backlog defines the length of this queue. You can read the full conversation here.

Alicaalicante answered 3/10, 2013 at 16:4 Comment(1)
Perhaps I'm not following you properly, but it sounds to me based on this page that NGINX has its own queue: nginx.com/blog/rate-limiting-nginx Can you explain if I'm missing something?Tamer

© 2022 - 2024 — McMap. All rights reserved.