lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> Here's a brief write-up benchmarking

Thanks for posting this, Berwyn.

I have recently been looking into a similar question as you did, i.e., creating web services using update-to-date PUC-Lua and NGINX.

As you write, a central issue is that some solutions only support LuaJIT. Moreover, the architecture of NGINX is non-blocking. This is at odds with substantial parts of the Lua ecosystem that are not non-blocking.

I ended up creating Lua Web Services for NGINX, or LWS for short. LWS works with PUC-Lua (tested with 5.3 and 5.4), and it uses a thread pool to run the Lua web services asynchronously. This way, the Lua code can block without blocking the NGINX event loop. LWS supports many directives, is well documented, and comes with a built-in monitor and profiler [1].

I did a simple reimplementation of your “multiply” benchmark. The initial execution time of the benchmark was 1.269 seconds, creating 400+ Lua states. Limiting the maximum number of Lua states (using lws_max_states 100) and thus queueing requests a bit reduced the execution time to 1.066 seconds, which is in line with your best performance.

Cheers, André