Overview of ngx_http_lua_module
masterThe ngx_http_lua_module embeds LuaJIT 2.0/2.1 into Nginx HTTP servers. It is a core component of OpenResty.
Key Features
- Non-blocking I/O: By leveraging Nginx's subrequests and Lua coroutines, Lua code can be 100% non-blocking on network traffic when using the provided Nginx API for Lua to handle upstream services (MySQL, PostgreSQL, Redis, etc.).
- Performance: Provides performance levels comparable to native C programs due to LuaJIT.
- Memory Efficiency: The Lua interpreter (Lua State) is shared across all requests in a single Nginx worker process, and request contexts are segregated using lightweight coroutines.
Scope
This module is plugged into the Nginx http subsystem. It handles downstream communication protocols in the HTTP family (HTTP 0.9/1.0/1.1/2.0, WebSockets, etc.). For generic TCP communications, use the ngx_stream_lua module instead.