Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Scaling

Scaling

DIGIT's microservices architecture is designed for horizontal scaling. Each service runs as a Kubernetes Deployment and can be independently scaled without affecting other services. The platform supports both manual scaling via replica count changes in Helm values and automatic scaling via Horizontal Pod Autoscaler (HPA).

Horizontal POD Autoscaling (HPA)

Kubernetes HPA automatically adjusts the number of pod replicas based on observed CPU or memory utilisation. Configure HPA in the service's Helm values or as a standalone Kubernetes resource:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: egov-workflow-v2
  namespace: egov
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: egov-workflow-v2
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70   # Scale out when CPU > 70%

Monitor HPA status with:

Manual Scaling Via Helm Values

For services with predictable load patterns, set replica counts directly in the environment values file and redeploy:

SERVICE
RECOMMENDED PROD REPLICAS

API Gateway (Zuul)

3 minimum. Front door for all traffic — keep HA. Scale first when seeing gateway timeouts.

egov-workflow-v2

2–3. Scales well horizontally. CPU-bound on complex workflow evaluations.

egov-persister

2–3. Kafka consumer — each replica handles a partition. Keep replicas ≤ Kafka partitions.

egov-indexer

2. Kafka consumer writing to ElasticSearch. Keep at 2 for HA.

egov-user

2–3. In the critical path of every API request (auth check). Keep replicas ≥ 2.

egov-notification-sms

1–2. IO-bound on SMS gateway. Scale if delivery latency increases.

PDF-service

2. CPU-intensive PDF generation. Scale for bulk certificate issuance periods.

Resource Requests & Limits

Set resource requests and limits for every service. Requests determine scheduling; limits prevent runaway memory consumption. Kubernetes evicts pods that exceed memory limits and CPU-throttles pods that exceed CPU limits.

SETTING
RECOMMENDATION
RISK IF MISSING

requests.cpu

50–200m for most DIGIT services. Higher for Workflow and Persister.

Pod may be scheduled on an overloaded node, degrading performance.

requests.memory

256–512Mi for Spring Boot services. 1–2Gi for ElasticSearch/Kafka.

Scheduler cannot make optimal placement decisions.

limits.cpu

2–3x the request value. CPU is compressible — throttling is safe.

Without limits, a noisy neighbour can starve other pods on the same node.

limits.memory

1.5–2x the request value. Closely match observed peak consumption.

Without limits, a memory leak causes an OOMKill of the pod (restart). With limits too tight, legitimate spikes cause OOMKills.

Identifying Performance Bottlenecks

SYMPTOM
LIKELY CAUSE
INVESTIGATION TOOL

High API response latency

Slow database query, Kafka consumer lag, overloaded Persister, or insufficient Workflow replicas

Jaeger tracing — find the slowest span in the request chain

Pod OOMKilled frequently

Memory limit too low, memory leak in service, or JVM heap not tuned

kubectl describe pod <pod> | grep -i oom; Grafana Pods dashboard

Kafka consumer lag growing

Persister or Indexer replicas insufficient, Kafka partition count too low, or downstream write bottleneck (DB/ES)

prometheus-kafka-exporter in Grafana; kubectl logs -n egov <persister-pod>

ElasticSearch index errors

Disk full, too many shards, or JVM heap exhaustion on ES nodes

GET /_cluster/health?pretty; ES-Curator to clear old indices

Node CPU throttling

Too many CPU-heavy services co-located on one node, or requests set too low

Grafana Nodes Overview; kubectl top nodes

DB connection pool exhausted

Service holding connections open too long, max_connections too low

Grafana or pg_stat_activity; tune pg pool size in service config

CAPACITY PLANNING GUIDELINES

GUIDELINE
DETAIL

Watch PVC fill rate

ElasticSearch and Kafka produce the most data. Alert at 70% and expand PVC before reaching 85%. ES-Curator should auto-delete old indices before this threshold is reached.

Node autoscaling

On cloud deployments (EKS/GKE/AKS), enable cluster autoscaler. On SDC, manually provision additional worker VMs as 70% average node utilisation is approached.

Kafka partitions

Kafka consumer parallelism is bounded by partition count. If Persister consumer lag grows and replicas are already at max, increase partition count (requires Kafka topic reconfiguration).

DB read replicas

Add a PostgreSQL read replica for analytics and reporting queries. Route read-heavy services (DSS, Indexer) to the replica to reduce load on the primary.

Peak load testing

Run load tests against UAT before major citizen-facing campaigns (tax payment deadlines, enrollment drives). Use k6 or JMeter targeting the API Gateway endpoint.

SRE team rituals

Conduct weekly infrastructure review (node headroom, PVC fill rate, consumer lag). Monthly capacity review against transaction growth projections.

Last updated

Was this helpful?