OpenResty® 通过 Lua 扩展 NGINX 实现的可伸缩的 Web 平台

最新! OpenResty 已发布。
最新! 新博客文章 如何从剧本文档自动生成演示谷歌搜索的视频 已发表。
最新! 新博客文章 新增针对 Debian 11 的 OpenResty 官方安装包仓库 已发表。

Lua Nginx Module

Yichun Zhang , 26 Aug 2011 (created 21 Jun 2011)

This module embeds the Lua interpreter or LuaJIT into the nginx core and integrates the powerful Lua threads (aka Lua coroutines) into the nginx event model by means of nginx subrequests.

Unlike Apache's mod_lua and Lighttpd's mod_magnet, Lua code written atop this module can be 100% non-blocking on network traffic as long as you use the ngx.location.capture or ngx.location.capture_multi interfaces to let the nginx core do all your requests to mysql, postgresql, memcached, upstream http web services, and etc etc etc (see ngx_drizzle, ngx_postgres, ngx_memc, and ngx_proxy modules for details).

The Lua interpreter instance is shared across all the requests in a single nginx worker process.

Request contexts are isolated from each other by means of Lua (lightweight) threads (aka Lua coroutines). And Lua modules loaded are persistent on the nginx worker process level. So the memory footprint is quite small even when your nginx worker process is handling 10K requests at the same time.


Project page: