S
S
speedvm2021-08-12 17:00:06
Nginx
speedvm, 2021-08-12 17:00:06

How to calculate fastcgi buffers for nginx?

Good day!

There is nginx + php-fpm. Everything works, but sometimes messages arrive in the logs:

... [warn] ... an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/2/00/0000000002 while reading upstream, client: 192.168.2.50, server: test.site, request: "GET /... HTTP/2.0", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", ...

Google suggests that you need to increase fastcgi_buffers and fastcgi_busy_buffers_size, but in all articles these parameters are increased without explanation, i.e. they write something like this: "Instead of 4k, put 32k and you will be happy."

Therefore, dear residents of the forum, I ask you to suggest how to calculate the value by which you need to increase the buffers, if, of course, this value can be calculated.

PS: I tried to include the debug level in nginx, I just got crazy from the amount of information that is poured there, but I did not find an answer to the question.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
speedvm, 2021-08-13
@speedvm

Here everything is compressed and the numbers at the end are quite clear:
Avg. 24807 --> fastcgi_buffer_size 32k;
Max. 629622 --> fastcgi_buffers 32 32k;
That is, if I understand correctly, fastcgi_buffer_size must be set so that the average value fits into it, and fastcgi_buffers should be set accordingly so that the maximum value fits.

R
rPman, 2021-08-12
@rPman

It is logical that the size of the buffer depends on the size of the response of your web server; if you set it less than typical, then the speed will slow down since the data will be 'cached' to a slow disk, if it is larger, then the data will remain in RAM, fast but occupying it.
the first result from Google gives a mini study with examples

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question