跑lighttpd做静态文件服务server时经常碰到的现象就是lighttpd本身不占用大内存,大部分内存被用到系统buffer cache上了。在所有静态文件加起来还不到内存的大小的情况下,buffer就不是问题。现在一般的服务器配置2~4G内存,而硬盘在100G以上。为了充分发挥大容量硬盘的优点,单靠2~4G BUFFER是不够的。
打开文件时用O_DIRECT的话,系统就不会使用buffer,而直接通过DMA存取文件。如果对大于5M的文件使用O_DIRECT打开,也许会解决部分BUFFER问题。有想法后,立马开始动手改lighttpd的network_linux_sendfile.c中的open,经过一天的测试,貌似没有解决问题,系统的IOWAIT也增加很多。en,可能这种修改方法不大对,我会再进行更深入的修改测试。
O_DIRECT gives you massive performance boost when it's used with aio. Try it.
I have figured out how to use AIO O_DIRECT on lighttpd, will try them later.
after you figure out AIO, would you please release that patch?
I am writing a plugin named 'mod_memcompress' that works like mod_compress. mod_memcompress stores compressed data in memory, removes LRU items from memory when used memory size reached upper limit.
memory is faster than speed of access disk file anyway, so I try the simpler way first
Will it really help? Why don't you try RAM-disk first?
RAMdisk is limited and can not adjust by lighttpd configuration.
namosys, Jan wants to talk to you about AIO