I have an API that receives anywhere from 1K to 20MB of data in each transmission. I also have a website that would only ever receive less than 10K in a single transmission. Both the API and the website are behind the same Nginx proxy server.
From the docs for client_body_buffer_size
If the request body size is more than the buffer size, then the entire (or partial) request body is written into a temporary file."
This means that any time I receive a request over the default, it will be written to disk.
Given that I can receive large payloads, would it be best to set the client_body_buffer_size
equal to client_max_body_size
, which for me is 20MB? I assume this would prevent nginx from writing the request to disk every time.
Are there any consequences to setting the client_body_buffer_size
so high? Would this affect the website, which never receives such large requests?
It depends on your server memory and how many traffic you have.
A simple formula: MAX_RAM = client_body_buffer_size X concurrent_traffic - OS_RAM - FS_CACHE.
(exactly the same thing with php-fpm pool tuning or even mysql/elasticsearch).
The key is to monitor all the things (RAM/CPU/Traffic) and change settings according your usage, star little of course then increase until you can.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With