ngx_lua_php_queue

nginx+lua+php+redis实现单业务排队系统架构

MIT License

Stars
113

ngx_lua_php_queue

nginx+lua+php+redis实现单业务排队系统架构

在做并发量很大的秒杀活动时,php会因为并发量过大而php进程不足导致服务器负载过大,无法同时处理过多请求,返回不友好的502错误。该项目旨在将php进程的压力转移到nginx层,使用lua作为中间语言,redis读取/储存队列信息,大大提高了并发量,降低了php进程的负载压力。

LICENSE: https://github.com/takatost/ngx_lua_php_queue/blob/master/LICENSE

安装

  1. 首先安装openrestyphpredis
  2. 安装完成后,将lua_scriptphp_scripts放入web文档目录,默认为/opt/htdocs/lua_queue
  3. 接着讲nginx/conf中的配置文件放入openresty的nginx配置文件目录,如/opt/ngx_openresty_1.7.2.1/nginx/conf
  4. 打开配置文件conf/vhosts/lua_queue.com.conf

原理

相关文档

  1. http://openresty.org/cn/index.html
  2. http://wiki.nginx.org/HttpRedis2Module