Skip to content

Resizing a PaaS managed DB node without dropping connections

How to scale a Jelastic managed Postgres or MySQL node up or down without forcing a hard reconnect on every active client. The mechanics, the verification, the safe path.

You hit 85% memory on the primary Postgres node of your managed PaaS cluster on a Tuesday afternoon. The dashboard offers a “Resize” button that promises live scaling. You click it on a staging environment first and watch every active session drop with connection reset by peer. The application’s pool reconnects in under a second, but a long-running COPY from the analytics job rolls back, the ORM’s prepared statements are gone, and the on-call gets paged for a transient 502 spike. The button worked. The expectation was wrong.

What’s happening

“Live resize” on a managed PaaS database node — Jelastic, the PaaS layer most managed providers run on top of — means the platform changes the cloudlet allocation (cgroup limits) on the container in place when scaling within a node, and recreates the container on a new host when crossing certain thresholds (RAM tier, CPU socket, storage class). The first kind is genuinely transparent to TCP sessions: the kernel sees a new memory ceiling, Postgres’s shared_buffers doesn’t change at runtime, but the OOM headroom does. The second kind — node migration — moves the volume to a new container, brings Postgres down for a clean shutdown, and brings it back up with the new resources. Active sessions terminate. The application’s connection pool reconnects. Anything mid-transaction rolls back.

The dashboard does not visually distinguish the two cases. The same “Apply” button can be either. Which one you get depends on what you change and the current placement. Resizing within the same RAM tier and storage class is in-place. Crossing the tier — typically the boundary where the platform reassigns you to a host with a different memory footprint — is a migration. For a write-path primary in production, you want the in-place version, scheduled around your traffic curve. For a read replica, either is fine — the application falls back to the writer.

How to verify

Before you click, check whether the proposed change crosses a tier. Using jelastic-cli:

# What you have now
jelastic environment control get-env-info \
  --envName "acme-prod-db" \
  --infra "myprovider.example.com" \
  --session "$JELASTIC_TOKEN" \
  | jq '.nodes[] | select(.nodeGroup=="sqldb") | {id, name, fixedCloudlets, flexibleCloudlets, ram, cpu}'

# What the target placement looks like for the new size
jelastic environment control set-cloudlets-count-by-group \
  --envName "acme-prod-db" \
  --nodeGroup "sqldb" \
  --fixedCloudlets 16 \
  --flexibleCloudlets 32 \
  --dryrun true \
  --session "$JELASTIC_TOKEN"

The dryrun response includes a migrationRequired flag. If it’s false, you can apply during business hours. If it’s true, schedule the change against your slowest hour and warn the application team that the pool will recycle.

Check the current pool state from the application side so you have a baseline:

# Postgres active sessions snapshot
psql -h db.acme-prod.internal -U app -d app -c "
SELECT state, count(*) FROM pg_stat_activity
WHERE backend_type = 'client backend' GROUP BY state;"

If the count is high (a few hundred) and the application uses long-lived transactions, a migration-style resize will surface as a thundering herd of reconnects when sessions all attempt to re-establish at once.

The fix

For a vertical scale within the same tier, the safe sequence:

# 1. Quiesce non-critical write paths: pause batch jobs that don't tolerate retries
#    (Sidekiq, Celery, cron) — application-specific, do this from your scheduler.

# 2. CHECKPOINT to flush dirty buffers so the OS sees less write pressure
psql -h db.acme-prod.internal -U postgres -d postgres -c "CHECKPOINT;"

# 3. Apply the resize in-place
jelastic environment control set-cloudlets-count-by-group \
  --envName "acme-prod-db" \
  --nodeGroup "sqldb" \
  --fixedCloudlets 16 \
  --flexibleCloudlets 32 \
  --session "$JELASTIC_TOKEN"

# 4. Wait for the operation to report success
jelastic environment control get-env-info \
  --envName "acme-prod-db" \
  --session "$JELASTIC_TOKEN" \
  | jq '.env.status'

# 5. Confirm Postgres sees the new memory ceiling
psql -h db.acme-prod.internal -U postgres -c "SHOW shared_buffers;"
psql -h db.acme-prod.internal -U postgres -c "SHOW effective_cache_size;"

Note that shared_buffers does NOT change automatically — it’s set at process startup. If you sized it for 8GB and you’ve now resized the container to 32GB RAM, you have 24GB of RAM the database isn’t using as cache. Schedule a restart to reload Postgres config with new values; this restart IS disruptive, plan it during a maintenance window or after a switchover to a replica.

For a tier-crossing resize on a primary, the zero-disruption path is:

  1. Resize a replica first (clients don’t care, the application uses the writer).
  2. Trigger a switchover via the PaaS UI or jelastic-cli — the replica becomes the new primary, sessions reconnect once to the new endpoint.
  3. Resize the old primary (now a replica) in place at the new tier.
  4. Optionally switch back, or leave it as-is.

This converts an unscheduled disruption into a planned 1-2 second reconnect window. The application’s connection pool needs to be configured to handle that gracefully — retry logic on connection errors, no assumptions about prepared statement persistence across reconnects.

Stack Harbor runs this kind of capacity change on your behalf as part of Cloud PaaS — we measure the steady-state, dry-run the resize, and execute the switchover during your traffic trough. If you’d like us to do the next capacity event with you on the call, book a scoping conversation.