Hi Team, I have a use case where I need to run a redis-server with 50 odd lua scripts for querying for different results. When I load the keys and the Lua scripts the memory usage looks all fine. But the soon I run the Lua scripts the memory shoots up for the server. When did info memory, used_memory_lua is really huge and even after the script run is complete this is not coming down. Is there any config knob for releasing these memory after the script run? Flushing the script is not an option for me as the script will be run again in future. Any pointers here would be helpful.
Hey @Anoop , can you give some more details?
- When you say memory is high, how high is it?
- What is the Redis version you are using.
- Out of the 50 scripts, can you find the script that cause the issue? And if so, can you share it?
Hi @meirsh Thanks, here are the info,
1:
With all loaded, no lua ran:
redis-cli -s redis.sock info memory | grep human
used_memory_human:483.14M
used_memory_rss_human:493.98M
used_memory_peak_human:483.14M
total_system_memory_human:3.85G
used_memory_lua_human:31.00K
used_memory_vm_total_human:63.00K
used_memory_scripts_human:184B
maxmemory_human:1.00G
After one script is run
used_memory_human:483.70M
used_memory_rss_human:1.77G
used_memory_peak_human:595.70M
total_system_memory_human:3.85G
used_memory_lua_human:1.16G
used_memory_vm_total_human:1.16G
used_memory_scripts_human:129.64K
maxmemory_human:1.00G
2: Redis version: Redis server v=7.0.5
3: Here is that script
local records = redis.call(‘ZRANGE’, ‘deletesortedappids’,‘0’, ‘-1’)
local rows= {}
for _, app_id in ipairs(records) do
local keys = redis.call(‘SMEMBERS’, app_id … “:specifickeys”)
for _, key in ipairs(keys) do
if string.find(key, “tblappstoeps:”) ~= nil then
local d = redis.call(‘HMGET’, key, ‘app_id’, ‘uuid’, ‘app_path’, ‘occurrence’, ‘last_seen’)
local row = {}
table.insert(row,string.format(“"%s":%s”, ‘app_id’, d[1]))
table.insert(row,string.format(“"%s":%s”, ‘uuid’, d[2]))
table.insert(row,string.format(“"%s":%s”, ‘app_path’, d[3]))
table.insert(row,string.format(“"%s":%s”, ‘occurrence’, d[4]))
table.insert(row,string.format(“"%s":%s”, ‘last_seen’, d[5]))
table.insert(rows,“{” … table.concat(row, “,”) … “}”)
end
end
end
return “{"records" : [” … table.concat(rows, “,”) … “]}”