Home / OCI

OCIHow-toIntermediate

HA web tier on OCI: instance pools across fault domains behind a load balancer

Build an instance configuration and instance pool spread over fault domains or ADs, attach it to a flexible load balancer with HTTP health checks, and add autoscaling and rolling updates.

Deepak Bhardwaj2 min read

Applies toOCI Compute instance pools, autoscaling configurations, OCI Flexible Load Balancer

1. Instance configuration (the template)

Create it from a golden instance, or define it in Terraform: shape, image (built by a pipeline), subnet, NSGs, cloud-init that pulls config and starts the app. No state on the instance.

oci compute-management instance-configuration create --compartment-id <cmp> \
  --instance-id <golden-instance-ocid> --display-name ic-web-v12 --source INSTANCE

2. Instance pool across FDs

oci compute-management instance-pool create --compartment-id <cmp> \
  --instance-configuration-id <ic-ocid> --size 3 \
  --placement-configurations '[{"availabilityDomain":"Abcd:AP-MUMBAI-1-AD-1","primarySubnetId":"<app-subnet-ocid>","faultDomains":["FAULT-DOMAIN-1","FAULT-DOMAIN-2","FAULT-DOMAIN-3"]}]' \
  --load-balancers '[{"loadBalancerId":"<lb-ocid>","backendSetName":"bs-web","port":8080,"vnicSelection":"PrimaryVnic"}]'

In multi-AD regions, add one placement configuration per AD.

3. Load balancer and health check

  • Flexible LB (min/max bandwidth) in a regional subnet; private for internal apps.
  • Backend set policy round robin or least connections; HTTP health check on /healthz returning 200.
  • Session persistence only if the app truly needs it (better: stateless app).
oci lb backend-set update --load-balancer-id <lb-ocid> --backend-set-name bs-web \
  --policy ROUND_ROBIN --health-checker-protocol HTTP --health-checker-port 8080 \
  --health-checker-url-path /healthz --health-checker-return-code 200 \
  --health-checker-interval-in-ms 10000 --health-checker-retries 3 --force

Allow the LB subnet to reach the backend port in the backend NSG.

4. Autoscaling

Metric-based autoscaling on CPU (scale out at 70%, in at 30%, cooldown 300 s), with min = 3 so losing one FD still leaves capacity.

5. Rolling updates

  1. Create a new instance configuration (new image version).
  2. Update the pool to use it.
  3. Replace instances gradually (detach/terminate one at a time, or scale up then down), checking LB backend health between steps.

6. Health and self-healing

Instance pools replace instances that are terminated or fail. Pair this with LB health monitoring: alarm on UnHealthyBackendServers > 0 and on HttpResponses5xx.

TLS

Terminate TLS on the LB with a certificate from OCI Certificates (auto-renewal), or pass through to backends if end-to-end TLS is required.

Tip

Put the WAF policy in front (OCI WAF attached to the LB) from the start. Adding it later often surfaces blocked requests that look like an outage.