3 ms·
This kind of stuff always makes me doubt why particular stacks are the most popular. Wondering, is the OpenResty solution otherwise single-threaded-with-an-eve
by skrebbel 15y ago
This kind of stuff always makes me doubt why particular stacks are the most popular.
Wondering, is the OpenResty solution otherwise single-threaded-with-an-eventloop much like node?
- justincormack 15y agoWell, you can configure how many processes nginx runs with at startup, but otherwise yes it is an event loop based system. Lua is just a module like anything else in Nginx, and uses the Nginx event loop.
- skrebbel 15y agoAh right, I see. From the nginx wiki: > 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, redis, upstream http web services, and etc etc etc (see HttpDrizzleModule, ngx_postgres, HttpMemcModule, HttpRedis2Module and HttpProxyModule modules for details). Is that talk-via-nginx-commands thing cumbersome in practice?
- SomeCallMeTim 15y agoNo, it's pretty easy. An example: local doc = ngx.location.capture( "/couchdb/hamster/"..uid ); This queries the local CouchDB for a particular user record, and stores it in a local variable.