<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hi Maxim,<br><br>I'm trying your suggestions<br><br>Here's the config that I used right now<br>worker_processes 10;<br>worker_rlimit_nofile 50000;<br>error_log /dev/null;<br><br>pid /etc/nginx/logs/nginx.pid;<br><br>events {<br> worker_connections 50000;<br> use epoll;<br>}<br><br>http {<br> include mime.types;<br> default_type application/octet-stream;<br><br> client_header_timeout 1m;<br>
client_body_timeout 1m;<br> client_header_buffer_size 24k;<br> large_client_header_buffers 32 256k;<br> send_timeout 1m;<br> ignore_invalid_headers on;<br> keepalive_timeout 5;<br> output_buffers 1 128k;<br> directio
1m;<br> server_tokens off;<br> location ~* ^.+\.(jpg|jpeg|png|gif|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$ {<br> aio on;<br> directio 1;<br> access_log off;<br> expires max;<br> }<br><br> location / {<br> aio
on;<br> directio 1;<br> try_files $uri $uri/ /index.php?$uri;<br> }<br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"> location ~ \.php$ {<br> fastcgi_pass 127.0.0.1:9000;<br> fastcgi_index index.php;<br> fastcgi_param SCRIPT_FILENAME $document_root/index.php;<br>
include /etc/nginx/conf/fastcgi_params;<br> }<br><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Maxim Dounin <mdounin@mdounin.ru><br><b><span style="font-weight: bold;">To:</span></b> nginx@nginx.org<br><b><span style="font-weight: bold;">Sent:</span></b> Thu, October 14, 2010 8:46:57 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: Image Hosting<br></font><br>
Hello!<br><br>On Thu, Oct 14, 2010 at 12:26:59PM +0000, <a ymailto="mailto:iptablez@yahoo.com" href="mailto:iptablez@yahoo.com">iptablez@yahoo.com</a> wrote:<br><br>> Actually the image size is arround 100KB each. The server is running in 250Mbps traffic. <br>> I already described the disk I'm using is scsi 15K RPM in raid 0<br><br>Basic tunings you have to apply when serving static which doesn't <br>fit into memory are:<br><br>If you use sendfile:<br><br>- Make sure your OS uses appropriate read-ahead for sendfile to <br>avoid trashing disks with small requests (and seeks). For FreeBSD <br>8.1+ it should be enough to set read_ahead directive in nginx <br>config (0.8.18+).<br><br><span><a target="_blank" href="http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#read_ahead">http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#read_ahead</a></span><br>(in Russian)<br><br>Using bigger socket buffers (listen ... sndbuf=... in nginx
<br>config) may help too.<br><br>- If serving large files - make sure you use appropriate <br>sendfile_max_chunk to avoid blocking nginx worker on disk for too <br>long.<br><br>- Consider switching sendfile off if you can't persuade it to read <br>large blocks from disk.<br><br>If not using sendfile:<br><br>- Tune output_buffers (again, to avoid trashing disks with small <br>requests and seeks). Default is 2x32k, which will result in 4 <br>disk requests for 100k file. Changing it to 1x128k would result <br>in 2x memory usage but 4x less disk requests, this is probably <br>good thing to do if you are disk-bound.<br><br>In both cases:<br><br>- Using aio may help a lot ("aio sendfile" is only available under <br>FreeBSD) by adding more concurency to disk load and generally <br>improving nginx interactivity. Though right now it requires <br>patches to avoid socket leaks, see here:<br><br><span><a target="_blank"
href="http://nginx.org/pipermail/nginx-devel/2010-October/000498.html">http://nginx.org/pipermail/nginx-devel/2010-October/000498.html</a></span><br><br>- Using directio may help to improve disk cache effictiveness by <br>excluding large files (if you have some) from cache. Though keep <br>in mind that it disables sendfile so if you generally tune for <br>sendfile - you may have to apply output_buffers tunings as well.<br><br>It's hard to say anything more than this without knowing lots of <br>details.<br><br>Maxim Dounin<br><br>_______________________________________________<br>nginx mailing list<br><a ymailto="mailto:nginx@nginx.org" href="mailto:nginx@nginx.org">nginx@nginx.org</a><br><span><a target="_blank" href="http://nginx.org/mailman/listinfo/nginx">http://nginx.org/mailman/listinfo/nginx</a></span><br></div></div>
</div><br>
</body></html>