NginxでWordPressを使っていると、特別チューニングしていなければ以下のようなワーニングが発生しているだろう。
[warn] 10211#0: *83 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000004, client: x.x.x.x, server: _, request: "POST /wp-admin/theme-editor.php HTTP/1.1", host: "example.com", referrer: "http://example.com/wp-admin/theme-editor.php?file=functions.php&theme=default&scrollto=0&updated=true"
投稿時やテーマ編集などで発生しやすく、「client_body_buffer_sizeのバッファサイズを超えたからファイルに書いたよ」というものだ。
これ自体特別悪いものではないが、編集が多ければログが不要なワーニングで埋め尽くされていってしまうし、ファイルIOも増えているということになる。メモリ利用率に関係するところなので比較的静的な運用サイトの場合は考えどころだが、個人で運用しているようなサイトでは、メモリサイズを増やして対処してしまったほうがすっきりするだろう。
対応するには、Nginxの設定ファイルの先頭のほうで、
client_body_buffer_size 64k;
のように記述して反映させておけば良い。たいていのLinux環境ではページサイズが4Kであり、8Kの設定になっているので、これを64Kと明示することになる。client_body_buffer_sizeの説明は以下のとおり。
client_body_buffer_size
Syntax: | client_body_buffer_size size |
Default: | 8k|16k |
Context: | http server location |
Reference: | client_body_buffer_size |
The directive specifies the client request 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.
The default size is equal to page size times 2. Depending on the platform, the page size is either 8K or 16K.
When the Content-Length request header specifies a smaller size value than the buffer size, then Nginx will use the smaller one. As a result, Nginx will not always allocate a buffer of this buffer size for every request.