5

I'm an iOS developer and my back end is all written in Django. I use gunicorn as my HTTP server. I have three workers running on a small EC2 instance.

My iOS app does not require any images or static content. At most, I am sending 1-20 JSON objects at a time per request. Each JSON object has at most about 5-10 fields.

I'm quite new to NGINX. I heard it can do proxy buffering. I would like to add proxy buffering for slow clients, but I don't know the appropriate specific settings to use for the following modules:

proxy_buffers
Syntax:     proxy_buffers number size
Default:    8 4k|8k
Context:    http server location
Reference:  proxy_buffers


proxy_busy_buffers_size
Syntax:     proxy_busy_buffers_size size
Default:    8k|16k
Context:    http server location
Reference:  proxy_busy_buffers_size

proxy_buffer_size
Syntax:     proxy_buffer_size size
Default:    4k|8k
Context:    http server location
Reference:  proxy_buffer_size

The only setting which I know how to use (which is pretty sad) is the one below:

proxy_buffering
Syntax:     proxy_buffering on | off
Default:    on
Context:    http server location
Reference:  proxy_buffering

Your expertise in this area would be greatly appreciated by this kind lost soul!

4

1 回答 1

7

proxy_buffers

定义 nginx将number创建多少缓冲区以及size每个缓冲区有多大。当 nginx 开始从上游接收数据时,它开始填充这些缓冲区,直到缓冲区已满或上游发送EOFEOT. 如果满足这两个条件中的任何一个,nginx 会将缓冲区的内容发送给客户端。

如果客户端没有足够快地读取缓冲区,它将尝试将它们的内容写入磁盘并在客户端能够接收时发送它们。

取 JSON 响应的平均大小。现代磁盘和文件系统甚至可以处理巨大的缓冲区大小,但是您应该使用 2 的幂,并且通过在数量和大小之间建立良好的平衡,您可以加快缓冲过程。

proxy_busy_buffers_size

这些是已经通过下游但尚未完全发送的缓冲区,因此它们不能被重用。该指令限制了此类缓冲区的最大总大小,因此允许使用剩余的缓冲区来读取上游响应。

proxy_buffer_size

始终在使用的主缓冲区。即使你禁用,nginx 仍然会填满这个缓冲区并在它满或/proxy_buffering时立即刷新它。EOFEOT

proxy_max_temp_file_size

该指令控制如果缓冲区已满(仍然使用内存缓冲区,因为您需要它们与磁盘通信),可以将多少数据写入磁盘。如果所有缓冲区和此文件已满,则 nginx 停止从上游读取并必须等待下游获取数据才能继续执行相同的过程。

于 2013-06-19T09:55:32.847 回答