R
Railway12mo ago
Yash

I have a celery app, how will app sleeping work?

Hey folks, I have a couple of celery apps that I restart every few hours to limit memory leaks or clean memory. I noticed there's app sleeping now, the restarts I do cause some jobs to fail prematurely. How will app sleeping work in celery based apps? Say my app consumes 200mb after it restarts, this goes to 2-3 GB after first job until it restarts again. Will app sleeping take this back to 200mb without having to restart? I have a bunch of apps and I don't want to waste memory. Thanks in advance
8 Replies
Percy
Percy12mo ago
Project ID: N/A
Brody
Brody12mo ago
assuming your celery apps can be slept, read the inactive service detection section https://docs.railway.app/reference/app-sleeping a sleep and wake cycle would indeed reset the memory, a sleep will send sigterm, and a wake is just running the container image. though since it's a worker, you would have to call it's public domain to wake it back up, it can't wake itself
Yash
Yash12mo ago
Yes, I use uvicorn to send tasks to celery Will that do?
Brody
Brody12mo ago
does that involve an http request to your celery worker on the public domain?
Yash
Yash12mo ago
Ah, nope, that's the issue Redis based queue
Brody
Brody12mo ago
a request to the public https domain, or to it's tcp proxy address and port are currently the only ways to wake a service. you could come up with something to port knock the workers public tcp proxy address to wake it before you send or ask for a job from the workers
Yash
Yash12mo ago
seems too technical for me, so will pick it up later on
Brody
Brody12mo ago
fair enough
Want results from more Discord servers?
Add your server