3 ms·
Lua support in nginx is phenomenal, especially when combined with LuaJIT. It basically allows to transform nginx into an application server and run arbitrary co
by sinzone 11y ago
Lua support in nginx is phenomenal, especially when combined with LuaJIT. It basically allows to transform nginx into an application server and run arbitrary code that can pretty much do anything.
I would like to mention agentzh and his team that did an amazing job in releasing OpenResty[1] which makes it easy to extend nginx with custom Lua functionality, which also happens to be the backbone of CloudFlare architecture, and the core technology being used by projects like Kong[2] when it comes to microservices management.
[1] http://openresty.org/ http://openresty.org/
[2] https://github.com/Mashape/kong https://github.com/Mashape/kong
- kator 11y ago+1 I built a nginx+luajit RTB bidder that did 168k qps on 8 cores. It smashed the C eventlib version and of course it crushed the Java version. Golang came in a close second but at the time with 8 cores I had to do crazy things to get it to pin to CPU's since the golang thread scheduling didn't seem very scaleable beyond 4 cores.
- lpgauth 11y ago168K/s? Did you actually decode the bid request (json) or just return no bid? That seems too good to be true.
- fit2rule 11y agoI also would love to know details about this .. very impressive stats!
- royjacobs 11y agoThese bidding platforms typically don't provide you with JSON but with some headers or query parameters that are very quick to parse (especially for the native nginx code), so your Lua code can basically boil down to a few table lookups.
- lpgauth 11y agoUh, look up OpenRTB. Except for Doubleclick Adx almost all exchanges encode bid requests in JSON.
- ww520 11y agoMay be I got it the wrong. Are the time spent on the bid processing portion (CPU bounded) or the network messaging and connection handling portion (IO bounded)? When talking about eventlib and nginx, I assume the network messaging and connection handling are relevant. In that case 168K requests/sec doesn't sound too great. This benchmark shows Ngix+Lua (openresty) is more than 5 times slower than the leading ones, which can do more than 6M requests/sec. https://www.techempower.com/benchmarks/#section=data-r11&hw=peak&test=plaintext https://www.techempower.com/benchmarks/#section=data-r11&hw=...
- jimjag 11y agoThe problem w/ engine's Lua support is that it doesn't go far enough. Apache's mod_lua allows you to create complete modules for Apache, with total access to Apache's API.