9 ms·
Lua is a funky little language and runtime but it is absolutely perfect for scripting in the domain that it was designed for: embedded. I used to do a lot of g
by VWWHFSfQ 6y ago
Lua is a funky little language and runtime but it is absolutely perfect for scripting in the domain that it was designed for: embedded.
I used to do a lot of game dev and it was incredible for testing different interactions/movements etc at runtime just to get all the inputs right and then implement in the game code. It has saved me probably 1,000s of man-hours in my career. Nowadays I use it in NGINX for high-velocity requests that are just backed by Redis. Lua, LuaJIT, and Redis have made me a lot of money in my career. I'm forever indebted to their incredible creators and community.
- arthurcolle 6y ago> Nowadays I use it in NGINX for high-velocity requests that are just backed by Redis. Can you talk more about this? Sounds like some dark magic
- leetrout 6y agoNot the OP but I used openresty (fork of nginx) to cache POST requests to Redis. It’s lightning fast. 16,000+ requests per second served from the cache.
- ethanpil 6y agoCan you point me in the right direction for this type of implementation?
- leetrout 6y agoThis came up from a quick google search https://blog.cloud66.com/supercharging-nginx-with-lua-part-3/ https://blog.cloud66.com/supercharging-nginx-with-lua-part-3...
- anonymoushn 6y agoAt one company that served a lot of requests from an Openresty cache, we used nginx's cache for caching full HTTP responses and lua-resty-mlcache for caching other things. lua-resty-mlcache requires one to provide a callback to get the data as a string, then a way to deserialize the string, because the l2 cache in nginx's shared memory zone will store the item as a string. We used msgpack for this part.
- VWWHFSfQ 6y agoWe use NGINX + Lua [1] to collect real-time diagnostic and performance data from physical machines while they operate. We collect about 150,000 data points (HTTP requests) per second with 2 NGINX servers and 2 Redis servers. We've benchmarked this particular server group up to almost a million req/s before it started to break down (median resp time > 100ms). [1] https://github.com/openresty/lua-nginx-module https://github.com/openresty/lua-nginx-module
- bepvte 6y agoDo you rely on redis persistence at all?
- ende42 6y agoWe recently implemented a simple streaming server based on Openresty and Redis. Redis is used as buffer. We load tested it up to 2000 mountpoints (128kbit mp3 streams) with 15.000 clients. The architecture has some nice properties. For example the buffer being not in-process means (besides an obvious performance hit) that the streaming server can be seamlessly redeployed without loosing the buffer. The Openresty Lua implementation is amazing.
- mpalfrey 6y ago+1 for Openresty Lua being great. It's saved my ass a few times.
- AceJohnny2 6y agoHow does it compare to TCL? I understand that the fact of the matter is that Lua dominates, but I'm curious if there are technical reasons or "right thing/right time" kind of luck, after TCL's star dimmed.
- corysama 6y agoDon't know much about TCL. But, if you are familiar with JavaScript, Lua ended up being semantically a much cleaner, simpler JS without all the WOT?? and committees to please. It is small, fast, simple, powerful and easy to embed. It's also very easy to contain in that the standard library is small and most of that can be removed easily. Isolating Lua's allocation arena and controlling Lua's GC is pretty easy.
- catalogia 6y agompv supports both Lua and Javascript scripting, with more or less the same API for both. The wiki lists 10 scripts from the community written in Javascript vs a few hundred written in Lua. There are probably network effects in play; people choose Lua because that allows them to mine snippets of code from a larger collection of userscripts. Even so though, I think it's a testament to Lua. https://github.com/mpv-player/mpv/wiki/User-Scripts https://github.com/mpv-player/mpv/wiki/User-Scripts
- panzagl 6y agoJavaScript moves so fast- it's gone from WAT to WOT
- hajile 6y agoAll the little operators that make things nice like += are missing. Their object implementation is meta-tables, so every single codebase does stuff in fundamentally different paradigms. Operator overloading in such a dynamic language makes things extremely hard to understand. While `"0" == 0` is false, the language will still sloppily convert between floats and ints and will also convert strings to numbers in other places. Worst of all, array indexes are base 1.
- rsecora 6y agoI can't agree more. Do you use any library for the binding? I use sol2.
- spacechild1 6y agoI can also recommend sol2 / sol3. It makes interoperability between lua and c++ almost seemless.
- stevekemp 6y agoAgreed entirely, but of course it can be embedded in more things than people might expect. For example redis, HAProxy, nginx, etc. I wrote a console-based mail-client which was configured and scripted entirely within lua. That was my solution to the weird not-quite-real configuration options available to mutt. I don't use it any more, and it never became terribly popular, but it was a wonderful fit.
- VadimPR 6y agoAgreed. We've embedded it inside Mudlet (https://github.com/Mudlet/Mudlet https://github.com/Mudlet/Mudlet) for a decade and people have started their careers in programming thanks to wanting to code for their favourite text game.
- huseyinkeles 6y ago> I'm forever indebted to their incredible creators and community. Consider donating some money to them if you aren't already :)