Skip to content

Cluster resize on Jelastic PaaS without downtime — order of operations and validation

A no-downtime cluster resize is a rolling sequence, not a single button press. Drain, validate, resize, validate, restore traffic — and run the same loop for every node.

The product team has scheduled a launch for Thursday at 10 AM. The current PaaS cluster has three application nodes at 16 cloudlets each, and analytics from the last campaign say you’ll need at least 32 to hold the curve. The window to resize is six business hours over Wednesday afternoon. Hitting “Change cloudlets” on the whole environment at once is the wrong move — it bounces every node, the connection pools all reset at the same time, and the cache layer goes cold in unison. A rolling resize, done in order, with validation at each step, lets you go from 3×16 to 3×32 without a single user-visible blip. The trick is that “no downtime” is not a feature of the PaaS — it’s an operational discipline.

What’s happening

Resizing a Jelastic node restarts the container that holds the application. For a stateless tier behind a load balancer, that means the node is briefly removed from rotation, resized, restarted, and brought back. If you do it correctly, the load balancer sees one node go away and N-1 nodes pick up the slack. If you do it wrong — by resizing the whole layer at once, or by skipping the drain step, or by not waiting for health before moving on — you either get a multi-node outage or a slow brownout where every node is warming caches simultaneously and capacity is below baseline for several minutes.

The order of operations matters because each step makes a guarantee that the next step depends on:

  1. Pre-flight validation — confirm cluster health is good before you start. You’re not resizing during an active incident.
  2. Drain one node — remove it from load balancer rotation, let in-flight requests complete.
  3. Resize that node — change cloudlets, restart container.
  4. Health-check — wait for the application to come back, caches to warm to acceptable level.
  5. Restore traffic — put it back in rotation.
  6. Validate at cluster level — check P95, error rate, queue depth haven’t moved.
  7. Repeat for next node with a deliberate pause between each.

Skipping any step costs you either availability or warmup time. The two most common mistakes: (a) skipping the drain step so in-flight requests get dropped, and (b) starting the next node’s resize before the previous one is fully warm — which compounds the warmup penalty across multiple nodes at once.

How to verify

Before starting, confirm the cluster is healthy and you have a clean baseline:

# 1. All nodes responding and in rotation on the LB
for n in cp01 cp02 cp03; do
  curl -fsS "http://${n}.internal:8080/health" \
    && echo "${n} OK" || echo "${n} FAIL"
done

# 2. No active incident — error rate is at baseline
curl -s http://prom:9090/api/v1/query \
  --data-urlencode 'query=sum(rate(http_requests_total{code=~"5.."}[5m])) 
                       / sum(rate(http_requests_total[5m]))' \
  | jq '.data.result[0].value[1]'

# 3. P95 latency at baseline (record this number — you'll compare after each node)
curl -s http://prom:9090/api/v1/query \
  --data-urlencode 'query=histogram_quantile(0.95, sum by (le) 
                       (rate(http_request_duration_seconds_bucket[2m])))' \
  | jq '.data.result[0].value[1]'

# 4. Queue depth flat (not building up)
curl -s -u admin:pass http://rabbit:15672/api/queues/%2f \
  | jq '[.[] | {name, messages_ready}] | sort_by(-.messages_ready)'

# 5. Confirm replica/leader state for stateful layers
patronictl -c /etc/patroni/patroni.yml list

If any check is dirty — an error rate above baseline, queue depth climbing, replication lag — abort. You don’t start a resize during an incident, period.

The fix

The full rolling-resize runbook for a stateless application tier on Jelastic. Save as /root/sh-rolling-resize.sh. It assumes you have the Jelastic API token in /etc/sh-jelastic.env and that the LB integration exposes per-node drain/enable.

#!/usr/bin/env bash
set -euo pipefail

### Stack Harbor rolling resize for Jelastic PaaS — stateless tier
### Resizes each node in sequence with health checks between
### Aborts on first failure; does NOT roll back automatically

source /etc/sh-jelastic.env  # JEL_API, JEL_TOKEN, ENV_NAME

NODE_GROUP="cp"
NEW_CLOUDLETS="${NEW_CLOUDLETS:-32}"
WARMUP_SECONDS="${WARMUP_SECONDS:-120}"
INTER_NODE_PAUSE="${INTER_NODE_PAUSE:-60}"
P95_BASELINE_MS="${P95_BASELINE_MS:-400}"
P95_TOLERANCE_MS="${P95_TOLERANCE_MS:-200}"

log() { echo "[$(date -u +%FT%TZ)] $*"; }

jel() {
  local method=$1; shift
  curl -fsS -X POST "${JEL_API}/1.0/environment/control/rest/${method}" \
    -d "session=${JEL_TOKEN}&envName=${ENV_NAME}&$*"
}

p95_ms() {
  curl -fsS http://prom:9090/api/v1/query \
    --data-urlencode 'query=histogram_quantile(0.95, sum by (le) 
                          (rate(http_request_duration_seconds_bucket[2m]))) * 1000' \
    | jq -r '.data.result[0].value[1] // "0"' | awk '{printf "%.0f", $0}'
}

error_rate() {
  curl -fsS http://prom:9090/api/v1/query \
    --data-urlencode 'query=sum(rate(http_requests_total{code=~"5.."}[2m])) 
                         / clamp_min(sum(rate(http_requests_total[2m])), 0.001)' \
    | jq -r '.data.result[0].value[1] // "0"'
}

drain_node() {
  local node_id=$1
  log "drain: removing node ${node_id} from LB rotation"
  jel "setnodedisplayname" "nodeid=${node_id}&displayname=DRAINING" >/dev/null
  jel "setnodecount" "lbName=nginx&nodeid=${node_id}&weight=0" >/dev/null || true
  sleep 15  # let in-flight requests drain
}

resize_node() {
  local node_id=$1
  log "resize: node ${node_id} -> ${NEW_CLOUDLETS} cloudlets"
  jel "setcloudletscount" \
      "nodeid=${node_id}&fixedCloudlets=${NEW_CLOUDLETS}&flexibleCloudlets=${NEW_CLOUDLETS}"
}

restore_node() {
  local node_id=$1
  log "restore: node ${node_id} back in rotation"
  jel "setnodecount" "lbName=nginx&nodeid=${node_id}&weight=1" >/dev/null
  jel "setnodedisplayname" "nodeid=${node_id}&displayname=cp" >/dev/null
}

wait_node_healthy() {
  local node_ip=$1
  log "waiting for ${node_ip} health"
  for i in {1..60}; do
    if curl -fsS "http://${node_ip}:8080/health" >/dev/null 2>&1; then
      log "${node_ip} responding"
      return 0
    fi
    sleep 5
  done
  log "FAIL: ${node_ip} did not become healthy in 5 minutes"
  return 1
}

validate_cluster() {
  local p95
  p95=$(p95_ms)
  local err
  err=$(error_rate)
  log "cluster P95=${p95}ms error_rate=${err}"
  local ceiling=$((P95_BASELINE_MS + P95_TOLERANCE_MS))
  if [[ "${p95}" -gt "${ceiling}" ]]; then
    log "FAIL: P95 ${p95}ms above ceiling ${ceiling}ms"
    return 1
  fi
  if awk "BEGIN {exit !(${err} > 0.01)}"; then
    log "FAIL: error rate ${err} above 1%"
    return 1
  fi
  return 0
}

#=== Pre-flight ===
log "pre-flight validation"
validate_cluster || { log "ABORT: cluster not healthy at start"; exit 1; }

#=== Enumerate nodes ===
NODES_JSON=$(jel "getenvinfo")
NODE_IDS=$(echo "${NODES_JSON}" | jq -r ".nodes[] | select(.nodeGroup==\"${NODE_GROUP}\") | .id")
log "nodes to resize: ${NODE_IDS}"

#=== Roll through each node ===
for nid in ${NODE_IDS}; do
  nip=$(echo "${NODES_JSON}" | jq -r ".nodes[] | select(.id==${nid}) | .intIP")
  log "============================================"
  log "starting node ${nid} (${nip})"
  log "============================================"

  drain_node "${nid}"
  resize_node "${nid}"
  wait_node_healthy "${nip}" || { log "ABORT on node ${nid}"; exit 1; }

  log "warmup ${WARMUP_SECONDS}s"
  sleep "${WARMUP_SECONDS}"

  restore_node "${nid}"

  log "validate cluster after node ${nid}"
  validate_cluster || { log "ABORT after node ${nid}"; exit 1; }

  log "inter-node pause ${INTER_NODE_PAUSE}s"
  sleep "${INTER_NODE_PAUSE}"
done

log "============================================"
log "rolling resize complete"
log "============================================"
validate_cluster

Run it with overrides:

NEW_CLOUDLETS=32 \
WARMUP_SECONDS=180 \
INTER_NODE_PAUSE=90 \
P95_BASELINE_MS=380 \
P95_TOLERANCE_MS=150 \
  /root/sh-rolling-resize.sh

A few notes on the assumptions:

  • Stateful tiers are not in scope for this script. Resizing a Postgres primary or a Redis master is a separate playbook — you do it via switchover (resize the replica first, switchover, then resize the now-replica). Don’t reuse this script for the data tier.
  • The drain step is best-effort. Jelastic’s LB integration varies; some setups need a manual nginx -s reload after the weight change. Test in staging first and confirm in-flight requests actually finish.
  • Aborting leaves the cluster in a mixed state. Some nodes resized, some not. That’s fine for stateless tiers — they work mixed — but you need to know it on the way in. The script does not roll back; rolling back is a separate decision after triage.
  • Warmup matters more than you think. For a stateless app this is 60-120 seconds. For an app with a large in-memory cache, it’s 5-10 minutes — and you’d rather pause longer between nodes than serve cold traffic to the full LB.

For cluster resizes run by an MSP that’s been through this loop on a hundred production environments, our Cloud PaaS team executes the rolling resize as part of environment management with the change recorded in the change log and the validation evidence attached. Start a scoping call if you’d rather not do the next launch-week resize at midnight.