Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
Hi @Ben-4222
The most useful clue is that the B2 instance passed the HTTP probe before the connection and pool checkout failures. The smaller Oryx artifact and faster startup helped get the app responding sooner, but they didn’t prevent the failure. The B1 worker recovering in the same process also means a restart wasn’t required. Neither observation tells us yet whether the bottleneck was connection setup, pool behavior, or worker scheduling.
For recycle reliability, I’d make the startup probe reflect actual readiness. On Linux App Service, set WEBSITE_WARMUP_PATH=/ready and WEBSITE_WARMUP_STATUSES=200. Without an explicit status list, even a 503 can count as a successful warm-up response. Have /ready report whether startup has established usable pool capacity, with a bounded wait; don’t open a new database connection on every ping. With multiple Gunicorn workers, make sure the result reflects the capacity you intend to serve; a response from one worker doesn’t prove the others are ready. App Service Health Check is separate and is most useful for routing around an unhealthy instance when you run at least two instances. Neither setting makes a single-instance recycle interruption-free.
A prebuilt custom container pinned to a specific image is a useful comparison: it takes Oryx packaging and extraction out of that test, but it won’t eliminate App Service recycles or fix a slow PostgreSQL handshake. If the goal is safer releases, consider a staging slot on Standard or higher, with swap warm-up configured separately. That helps with deployments; it doesn’t make direct production app-setting edits restart-free.
For the next repro, capture three things on the same timeline:
- Container and worker: Log UTC timestamps, App Service instance ID, a unique startup ID, and worker PID for process start, readiness changes, and first successful work. Add a per-worker event-loop lag measurement to spot stalls; lag alone doesn’t prove CPU scheduling was the cause.
- Connection and pool: Log physical connect start/end separately from checkout start/end and connection return. Include exception type, elapsed time, configured deadline, and available/in-use/waiting counts where the pool exposes them. If the driver only reports a combined connect duration, label it that way rather than attributing it to DNS, TCP, TLS, or authentication. Also verify that each worker creates its pool after fork if Gunicorn preload is enabled.
- Database: If this is Azure Database for PostgreSQL Flexible Server, enable server logs before the test and correlate connection events with client attempts using UTC and a non-sensitive application_name. Capture the first successful checkout and the first completed unit of work after recovery. Those are better recovery markers than the first HTTP 200.
For a support follow-up, send one failed recycle and one healthy control with the same image and worker settings. The key question is whether new physical connections were still failing when the slots became unavailable, or whether connections could already succeed while workers were still waiting for a slot. That distinction gives you a much better lead than another B1/B2 comparison.
References:
- App Service warm-up settings
- Health Check
- Custom containers
- Deployment slots
- PostgreSQL Flexible Server logs
Help make this community better for everyone: If this answer helped or resolved your issue, please accept it or upvote it. If not, share more details in a comment so we can continue the discussion and find the right solution. Thank you.