Real World Example

Scaling for a Flash Sale

An e-commerce company (think Myntra End of Reason Sale) expects 10x traffic at 12:00 noon. With Kubernetes, the team prepares like this:

  • Pre-scale the hot services the night before: minReplicas of product-service 6 → 20, order-service 3 → 12.
  • The HPA scales further on CPU; the cluster autoscaler adds nodes when Pods cannot be scheduled.
  • Readiness probes keep cold Pods out of rotation until caches are warm.
  • A PodDisruptionBudget stops node maintenance from taking down more than one order Pod at a time.
  • After the sale, minReplicas go back down to save cost.

Production Manifests for product-service

product-service

k8s/product-service/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: product-service
  namespace: shopease
spec:
  replicas: 6
  selector:
    matchLabels:
      app: product-service
  template:
    metadata:
      labels:
        app: product-service
    spec:
      topologySpreadConstraints:            # spread Pods across zones (asia-south1-a/b/c)
        - maxSkew: 1
          topologyKey: topology.kubernetes.io/zone
          whenUnsatisfiable: ScheduleAnyway
          labelSelector:
            matchLabels:
              app: product-service
      containers:
        - name: product-service
          image: ghcr.io/shopease/product-service:3.2.0
          ports:
            - name: http
              containerPort: 8081
          envFrom:
            - configMapRef: { name: product-service-config }
            - secretRef: { name: product-service-secrets }
          resources:
            requests: { cpu: 500m, memory: 768Mi }
            limits: { memory: 1Gi }
          readinessProbe:
            httpGet: { path: /actuator/health/readiness, port: http }
          livenessProbe:
            httpGet: { path: /actuator/health/liveness, port: http }
          startupProbe:
            httpGet: { path: /actuator/health/liveness, port: http }
            failureThreshold: 30
            periodSeconds: 2
          lifecycle:
            preStop:
              exec:
                command: ["sh", "-c", "sleep 5"]
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: product-service
  namespace: shopease
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      app: product-service

Example output

$ kubectl apply -f k8s/product-service/
deployment.apps/product-service configured
poddisruptionbudget.policy/product-service created
$ kubectl rollout status deploy/product-service -n shopease
deployment "product-service" successfully rolled out