简体   繁体   English

Nginx是否有单独的请求排队机制?

[英]Does Nginx have separate queuing mechanism for requests?

Consider the following situation: you are deploying application that can serve 1 req./sec. 请考虑以下情况:您正在部署可以提供1 req./sec的应用程序。 What would happen if I send 10 request in 1 second? 如果我在1秒内发送10个请求会怎么样? I wrote simple app to test that: https://github.com/amezhenin/nginx_slow_upstream . 我写了一个简单的应用程序来测试: https//github.com/amezhenin/nginx_slow_upstream This test shows that your requests will be served _in_exact_same_order_ they were sent. 此测试显示您的请求将被发送_in_exact_same_order_。

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. 现在,这看起来像Nginx有一些请求队列,但我的同事(管理员)说Nginx中没有任何队列。 So I wrote another question about epoll here: Does epoll preserve the order in which fd's was registered? 所以我在这里写了一个关于epoll的问题: epoll是否保留了fd注册的顺序? . From that discussion I figured that epoll does preserves the order of requests. 从那次讨论中我发现epoll确实保留了请求的顺序。

I have two questions: 我有两个问题:

1) Is there any mistakes in reasoning/code above? 1)上面的推理/代码是否有任何错误?

2) Does Nginx have some sort of queue for requests on top of epoll? 2)Nginx是否在epoll之上有一些请求队列? Or Nginx uses pure epoll functionality? 或者Nginx使用纯epoll功能?

Thank you, and sorry for my English :) 谢谢,抱歉我的英文:)

Nginx doesn't have it own queue, instead he pushes all requests to application server, which have listen socket: Nginx没有自己的队列,而是将所有请求推送到具有listen套接字的应用服务器:

#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. backlog定义了这个队列的长度。 You can read full conversation here . 你可以在这里阅读完整的对话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM