Nginx is a widely used webserver, which ranks for better choice to serve static and dynamic web content faster. In present era, computing resources are shaped up in broader room. Optimization of service holds up as a priority to use these resources optimally. Nginx optimization is the one, which this article speaks about.
Generally in linux systems, nginx config files can be located in /etc/nginx among it nginx.conf is main config file. Tuning parameters found in this file to correct values thumbs up performance. Following points projects how to do it.
I. nginx.conf
1. "worker_processes":
- It can be considered as one worker process per processor core.
2. "worker_connections":
3. "sendfile":
4. "keepalive_timeout"
5. "open_file_cache"
- It helps nginx to keep open file descriptors (modification time, file and directory parameters) to serve fast. "open_file_cache max=10000 inactive=30s" Sets maximum of 10000 files and valid for 30 sec, can be tuned respective to available memory.
6. "open_file_cache_min_uses"
7. "client_max_body_size"
- It is which client maximum request body size. Tune it with proper value to avoid (413 Request entity to large error), here we keep it as 100MB. "client_max_body_size 100M"
8. "client_body_buffer_size"
9. "server_names_hash_bucket_size"
10. "gzip"
11. "access_log"
II. Virtual host file:
1. Cache Control for Static Files
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_connect_timeout 360s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
}
These config makes nginx to perform better, when compared to default settings.
- See more at: http://ktree.com/blog/Nginx-Performance-Optimisation.html#sthash.BPYV7zQ9.dpuf
No comments:
Post a Comment