fastcgi_temp_file_write_size

The `fastcgi_temp_file_write_size` directive configures the maximum size of temporary files that can be written by FastCGI responses.

Syntaxfastcgi_temp_file_write_size size;
Default8k
Contexthttp, server, location
Arguments1

Description

The fastcgi_temp_file_write_size directive in NGINX is used to define the maximum size of temporary files that the FastCGI module can write to when processing requests. This directive is particularly useful when dealing with large responses, as it helps manage memory and disk usage effectively, reducing the risk of server overload. By setting this directive, administrators can increase or decrease the allowable size based on the expected FastCGI response sizes.

This directive accepts a single argument, which is a size value (bytes). If the size of the response exceeds the specified limit, the response will be written to a temporary file rather than directly into memory. This mitigates memory usage spikes and allows the server to handle more requests efficiently by utilizing disk space when necessary.

This directive can be set in any context: http, server, or location, making it flexible for various configurations. However, it is essential to consider the available disk space and the performance implications of writing to disk when configuring this directive. An appropriate value should be chosen based on the application’s normal load and the characteristics of the FastCGI responses.

Config Example

http {
    fastcgi_temp_file_write_size 16k;
}

Setting this value too low may result in frequent writing to disk, which can degrade performance.

If set too high without sufficient disk space, it may lead to writing failures or service outages.

← Back to all directives