Redis keeps crashing

Hey everyone, We migrate our infrastructure on Railway. The problem is that Redis is crashing and we don't know how to solve, there is no crash logs and we just see Memory spikes. We also saw a warning and want to add 'vm.overcommit_memory = 1' to /etc/sysctl.conf but don't know how to do it in the interface of Railway.
1:M 16 Jun 2023 20:03:43.296 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 16 Jun 2023 20:03:43.296 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
How can we avoid these crashes ?
40 Replies
Percy
Percy2y ago
Project ID: 66a8764a-14a2-4e1a-980a-79971c3d9cfb
Rafal - Pirate nation quest
66a8764a-14a2-4e1a-980a-79971c3d9cfb
Brody
Brody2y ago
looks like redis is trying to use more than 32 gb of ram
Rafal - Pirate nation quest
can we avoid the crash when he try it?
Brody
Brody2y ago
since you cant configure anything in redis.conf, the answer would be an unfortunate no. maybe we can pull the team in on this and see what can be done @Angelo - redis crashing with out of memory on the teams plan
Rafal - Pirate nation quest
should i try with my own dockerfile containing a redis ?
angelo
angelo2y ago
You can, but the crash is coming from the OOM
Brody
Brody2y ago
no docker volumes yet, so thats not feasible
Rafal - Pirate nation quest
what should i do? use an other service for redis?
Brody
Brody2y ago
lets see what the team can do for you here
angelo
angelo2y ago
I will need more info on what you are using Redis for and in the meantime, bump the container limit beyond 32GB but I don't have much info from you as much as I'd like to help
Rafal - Pirate nation quest
we are storing some data in cache and also use it for pub/sub client the data are mainly json object and some railway app are connected to redis and publish these json (around 50 json per sec) and some data consume it as subscriber Is this answer your questions? We had kubernetes before and the infrastructure with redis was working pretty well
angelo
angelo2y ago
Yep, forgive me as I am coordinating other issues, you can either deploy a Dockerfile (we are shipping volumes this month) with your own tuning or I can raise the limit to help you deal with the OOM issue
Rafal - Pirate nation quest
im having trouble deploying a dockerfile i dont know how to expose the docker and connect from other railway apps i can connnect myself from localhost but when i add a domain and try to connect on it its not finding anything
Brody
Brody2y ago
you are trying to deploy your own redis?
Brody
Brody2y ago
im really not sure why angelo told you to try to deploy your own redis instance, it cant work, for 2 reasons: 1. theres no persistent storage yet, data would be lost on redeploys 2. you wouldn't even be able to access the redis instance, railway's proxy will only proxy the http protocol, redis uses RESP
Ray
Ray2y ago
that’s for when we beta launch persistent volumes, which is super soon 😛 I’ll bump the memory limit for you to 64G Is this over Redis pub/sub? Alright done, your Redis now has 64gb mem limit. vm.overcommit_memory wouldn't help in this case, the issue is you're hitting the upper bound of the limit. Do you happen to know how much memory this was consuming in your previous kube deployment? Curious if there's some tuning that would help here; looks like you just have lots of data. And anyway, this is Redis so lack of persistent vol is totally ok (unless you're relying on persistence with AOF). You can just deploy a custom instance with your tuning if you like, but you'll just run into the same issue here.
Rafal - Pirate nation quest
Ok didn' understood it well sorry It's keep crashing every 5 min .. Yes redis pub/sub
Brody
Brody2y ago
what does the memory graph look like now?
Rafal - Pirate nation quest
In the previous one, have 1 node pool with 7 nodes of 2.5 RAM and 2 CPU each I dont rely on persistance so its ok
Brody
Brody2y ago
oh Angelo was probably guessing you would communicate to your own redis instance through the internal networking then yeah, for sure go ahead and spin up your own customised redis service
Rafal - Pirate nation quest
i have some trouble to exposing it from railway to public
Brody
Brody2y ago
you don't need to expose it publicly, that won't work anyways
Rafal - Pirate nation quest
how can i connect others services to the redis?
Brody
Brody2y ago
did you not hear about internal networking??
Rafal - Pirate nation quest
we have some other cloud providers
Brody
Brody2y ago
well railway has it too now https://discord.com/channels/713503345364697088/921233523719946260/1119371998452264990 this allows you to run your own redis instance
Brody
Brody2y ago
makes sense do /beta for access
Rafal - Pirate nation quest
yeah but private networking will only makes the redis accessible from railway apps i would like to expose it so i can access also from some aws apps
Brody
Brody2y ago
ah gotcha, exposing services that run something other than http isn't possible right now is there maybe possibly some in app tuning you could do with your code?
Rafal - Pirate nation quest
to limit reqs per sec on redis?
Brody
Brody2y ago
something like that, or manually clearing the cache on redis?
Rafal - Pirate nation quest
the problem will be the same, the redis will grow and instead of taking 5 min to crash it will take 20 min to crash and we dont store pub/sub in the cache it should quickly wipe the cache used is less than 500 mb
Brody
Brody2y ago
then what's causing memory to spike above 64gb? that's frankly an insain amount imo
Ray
Ray2y ago
^ needs to be answered first, because the issue is you're running into memory limits. Somewhere, your application is pushing a gigantic amount to Redis (and then flushing it by the looks of your metrics). We're happy to raise that limit for you, but you'll just run into the same issues again 😕
Want results from more Discord servers?
Add your server