Open karszawa opened 6 years ago
アプリケーションに依存しない設定一覧をまとめておく
いろいろ
ログの出力設定
log_format ltsv "time:$time_local" "\thost:$remote_addr" "\tforwardedfor:$http_x_forwarded_for" "\treq:$request" "\tstatus:$status" "\tmethod:$request_method" "\turi:$request_uri" "\tsize:$body_bytes_sent" "\treferer:$http_referer" "\tua:$http_user_agent" "\treqtime:$request_time" "\tcache:$upstream_http_x_cache" "\truntime:$upstream_http_x_runtime" "\tapptime:$upstream_response_time" "\tvhost:$host"; access_log /var/log/nginx/access.log ltsv;
レスポンス高速化の設定
etag off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65;
静的ファイル配信スニペット
server { location ~ ^/(fonts|img|css|js|favicon.ico) { open_file_cache max=100; root /home/isucon/webapp/static; expires 10d; } }
gzip配信スニペット
gzip on; gzip_disable "msie6"; gzip_types text/css application/javascript text/javascript; gzip_buffers 1000 64k; gzip_comp_level 8; gzip_vary on; gzip_static on;
unix domain socket
upstream app { server unix:/var/run/webapp/webapp.sock; }
gzip配信については結構ベンチマーカー次第なところがあるので保留。 ネットワークが律速になったら取り組む。
参考: ISUCON5 過去問で書いた例(gistでやれ)
worker_processes 1; events { worker_connections 2048; } http { log_format ltsv "time:$time_local" "\thost:$remote_addr" "\tforwardedfor:$http_x_forwarded_for" "\treq:$request" "\tstatus:$status" "\tmethod:$request_method" "\turi:$request_uri" "\tsize:$body_bytes_sent" "\treferer:$http_referer" "\tua:$http_user_agent" "\treqtime:$request_time" "\tcache:$upstream_http_x_cache" "\truntime:$upstream_http_x_runtime" "\tapptime:$upstream_response_time" "\tvhost:$host"; access_log /var/log/nginx/access.log ltsv; include /etc/nginx/mime.types; etag off; sendfile on; tcp_nopush on; tcp_nodelay on; upstream app { server unix:/var/run/webapp/webapp.sock; } server { location ~ ^/(fonts|img|css|js|favicon.ico) { etag off; # キャッシュを確認する仕組み。複数サーバのときはetagが一致しなくてキャッシュが利用されないことがあるので取り敢えずOFFにしておく expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; open_file_cache max=100; root /home/isucon/webapp/static; } location / { proxy_set_header Host $host; proxy_pass http://app/; } } }
なにをやるか
アプリケーションに依存しない設定一覧をまとめておく
なぜやるか
いろいろ
どうやるか
ログの出力設定
レスポンス高速化の設定
静的ファイル配信スニペット
gzip配信スニペット
unix domain socket
gzip配信については結構ベンチマーカー次第なところがあるので保留。 ネットワークが律速になったら取り組む。
参考: ISUCON5 過去問で書いた例(gistでやれ)