4 ms·
Excellent article! The use of Lua solves a lot of potential issues here with competing writes to similar spaces for rate limiting, causing potential bizarre er
by chucky_z 9y ago
Excellent article! The use of Lua solves a lot of potential issues here with competing writes to similar spaces for rate limiting, causing potential bizarre errors.
The one thing I would note that doesn't seem to be covered is if you are using a relatively large Lua script and running eval over and over it's getting cached every time, instead `SCRIPT LOAD ...` can be ran, which spits out a sha1 which can then be ran with `EVALSHA (sha1) (keys) (args)`. This can potentially speed stuff up as well as cutting back on memory.
- hamandcheese 9y agoBut requires extra logic and possibly tooling to do that correctly. The scripts aren’t persisted iirc, so if a node restarts the script won’t be loaded.
- ddorian43 9y agoIts Builtin in most clients.
- sciurus 9y agoTrue, but the performance difference can be huge. It's reasonable to illustrate things in a blog post just using EVAL, but you should be using EVALSHA for almost any production workload.
- simonw 9y agoClient libraries can handle this automatically: you can send the EVALSHA command and it will either execute successfully or reply with "I don't know what that script is" - then the client can re-send with the full script.