Powered by Typecho)))
Optimized by EAimTY
Nginx 性能优异在于善于利用操作系统内核的各种特性,比如 aio/epoll/sendfile (Linux), kqueue (FreeBSD) 等。对于使用 VPS 做图片站的站长来说,使用 nginx 的 aio 特性会大大提高性能,图片站的特点是大量的读 io 操作,nginx aio 不用等待每次 io 的结果有助于并发处理大量 io 和提高 nginx 处理效率。
前段时间有位客户要用 nginx aio,他用 rpm 升级安装 nginx 到 0.8.5 版本时候发现 rpm 包里的 nginx 没有包含 Linux-native aio (asynchronous I/O) 的支持,所以需要下载 nginx 源代码并带上参数 –with-file-aio 编译。除了要带参数外,Linux 内核还必须有支持这一特性的 api,eventfd(),否则在 nginx 错误日志(/var/log/nginx/error.log)里会看到类似的报错:
eventfd() failed (38: Function not implemented)
worker process 1858 exited with fatal code 2 and can not be respawn