diff --git a/q4-scalability/architecture.png b/q4-scalability/architecture.png new file mode 100644 index 0000000..ea4932c Binary files /dev/null and b/q4-scalability/architecture.png differ diff --git a/q4-scalability/calculations.md b/q4-scalability/calculations.md index 1bf0e3e..fb63a00 100644 --- a/q4-scalability/calculations.md +++ b/q4-scalability/calculations.md @@ -1,55 +1,58 @@ -# Scalability and Load Balancing +# Q4 - Scalability and Load Balancing -## 1. Required Number of Containers +## 1. Architecture Overview -### Given +The application is deployed behind a Load Balancer that distributes incoming traffic across multiple application containers. -- Incoming traffic = **15,000 requests/second** -- One container can handle = **500 requests/second** -- Safety margin = **30%** +Components: -### Calculation - -Required containers without margin: - -15000 ÷ 500 = **30 containers** - -Adding a 30% safety margin: - -30 × 1.30 = **39 containers** - -Rounded up: - -**40 containers** +- Users +- Load Balancer +- Container Cluster +- Ghaymah Block Storage +- Database --- -## 2. Cold Start Strategy +## 2. Required Number of Containers -To reduce startup delays during traffic spikes, the following strategy is recommended: +Application Load = 15,000 requests/second -- Keep at least 2 containers always running. -- Enable Horizontal Pod Autoscaler (HPA). -- Cache container images on cluster nodes. -- Use lightweight Docker images. -- Configure Readiness Probes before sending traffic to new containers. -- Scale gradually to avoid resource spikes. +One Container Capacity = 500 requests/second + +Required Containers: + +15000 / 500 = 30 Containers + +Safety Margin (30%): + +30 × 1.30 = 39 Containers + +Final Answer: + +**39 Containers** --- -## 3. Using Ghaymah Block Storage +## 3. Cold Start Strategy -Ghaymah Block Storage should be used for stateful workloads that require persistent storage. +To reduce cold start latency: -Examples include: +- Keep a small number of warm containers running. +- Enable Auto Scaling based on CPU and request rate. +- Perform health checks before routing traffic. +- Register new containers with the Load Balancer only after becoming healthy. +- Use lightweight container images for faster startup. -- PostgreSQL -- MySQL -- MongoDB +--- + +## 4. Ghaymah Block Storage + +Block Storage is used for stateful workloads such as databases. Benefits: -- Data persists even if a container restarts. -- High reliability. -- Easy storage expansion. -- Suitable for production databases. +- Data persists even if containers restart. +- Supports high availability. +- Can be attached to replacement containers. +- Suitable for MySQL, PostgreSQL, MongoDB and other databases.