Replit Autoscale deployment: database connection pool lifetime during scale-to-zero
0 reputation · 10 Sept 2021, 08:17 UTC
Context
Replit offers two deployment models: Autoscale deployments that scale to zero on inactivity and cold-start on demand, and Reserved VM (Always On) deployments that keep a process running continuously. Applications using managed PostgreSQL integrations typically configure a connection pool in the application layer.
Unresolved behavior
When an Autoscale deployment scales to zero, the underlying process terminates. It is unclear from current documentation whether pooled database connections are explicitly closed and discarded during that shutdown, or whether the pool is simply abandoned and recreated on the next cold start. The distinction affects pool sizing, connection churn on the database side, and the likelihood of transient exhaustion during rapid scale-up.
Goal
Determine the exact connection lifecycle for managed PostgreSQL when an Autoscale deployment transitions from idle to active, so that pool configuration can be matched to the platform's actual behavior.
Does the platform send a termination signal that allows graceful pool drain? Is the pool rebuilt from scratch on each cold start? Are there differences between the built-in key-value store and external PostgreSQL integrations in this regard?