I'm evaluating the use of lua scrips in redis, and they seem to be a bit slow. I a benchmark as follows:
- For a non-lua version, I did a simple
SET key_i val_i1M times - For a lua version, I did the same thing, but in a script:
EVAL "SET KEYS[1] ARGV[1]" 1 key_i val_i
Testing on my laptop, the lua version is about 3x slower than the non-lua version. I understand that lua is a scripting language, not compiled, etc. etc. but this seems like a lot of performance overhead--is this normal?
Assuming this is indeed normal, are there any workaround? Is there a way to implement a script in a faster language, such as C (which redis is written in) to achieve better performance?
Edit: I am testing this using the go code located here: https://gist.github.com/ortutay/6c4a02dee0325a608941