# Scalability Design

## 1. Architecture

The application is deployed on a Kubernetes cluster hosted on Ghaymah Cloud.

Incoming traffic is distributed through a Ghaymah Load Balancer across multiple application containers. The application stores persistent data using Ghaymah Block Storage, which is mounted as a Persistent Volume.

---

## 2. Required Number of Containers

### Given

- Incoming traffic = **15,000 requests/second**
- One container handles = **500 requests/second**
- Safety margin = **30%**

### Step 1

Base number of containers

15000 / 500 = 30 containers

### Step 2

Add 30% capacity

30 × 1.3 = 39 containers

### Final Answer

**39 containers**

---

## 3. Cold Start Strategy

To reduce startup latency for newly created containers:

- Keep a minimum number of warm replicas running.
- Use Kubernetes readiness probes before routing traffic.
- Pull container images in advance on cluster nodes.
- Use Horizontal Pod Autoscaler (HPA) to scale before traffic reaches peak levels.
- Deploy applications with rolling updates to avoid downtime.

---

## 4. Using Ghaymah Block Storage

Ghaymah Block Storage provides persistent storage for stateful workloads.

Typical use cases include:

- Databases
- PostgreSQL
- MySQL
- Redis persistence
- Application uploaded files
- Persistent logs

Benefits:

- Data persists even if a container is recreated.
- Storage can be attached to new containers.
- Reliable and durable storage for production workloads.
