I'm currently managing several Azure App Services that maintain long-lived WebSocket connections. Lately, I've noticed that these services restart unexpectedly, which I suspect might be due to Azure's container updates. I found that setting CI_DOCKER_ENABLED to false helps reduce the frequency of these restarts, but they still happen on occasion, which is frustrating. Is there a way to prevent Azure from interfering with my container setup and these random restarts?
5 Answers
It's essential to prepare for the possibility of disconnections and restarts. Your application should ideally detect these events and quickly attempt to reconnect. This is particularly crucial for services where downtime can impact users, like trading.
Unfortunately, you can't completely avoid restarts. The more premium workload profiles allow you to set a maintenance window, which might help manage when restarts occur. That's your best shot at minimizing disruptions.
You can't fully prevent the restarts, but timing them with a maintenance window can help. You should also keep in mind that hardware failures will still happen regardless. Consider making your application more resilient to these kinds of issues.
Are you using heartbeats to keep your WebSocket connections alive? In my experience with container app environments, we have several long-lived connections, and we rarely encounter restarts.
Have you checked if something like an out-of-memory (OOM) issue is triggering the restarts? It's also possible that Azure is maintaining the underlying hosts. Since you're using a managed service, some control is out of your hands. The best practice is to design your app to be stateless or switch to a platform where you have more control.
Related Questions
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads