Lab 20: Capstone — High-Availability Database

Time: 60 minutes | Level: Advanced | DB: MySQL + Redis + Elasticsearch

Overview

Build a complete HA database architecture demonstrating the full data flow: write to MySQL primary → ProxySQL routes reads/writes → Redis caches hot data → Elasticsearch indexes for search. This integrates all concepts from Labs 01-19.


Architecture Diagram

                    ┌─────────────────────────────────────────┐
                    │          Application Layer               │
                    │   (Python demo app / curl / redis-cli)   │
                    └──────────────┬──────────────────────────┘

               ┌───────────────────┼───────────────┐
               │                   │               │
          WRITE PATH          READ PATH         SEARCH
               │                   │               │
    ┌──────────▼──────┐   ┌────────▼────────┐   ┌──▼──────────────┐
    │   ProxySQL      │   │   Redis Cache   │   │ Elasticsearch   │
    │   (port 6033)   │   │   (port 6379)   │   │  (port 9200)    │
    └──────┬──────────┘   └─────────────────┘   └────────────────-┘

    ┌──────▼──────────────────────┐
    │         MySQL Cluster       │
    │  ┌─────────┐  ┌──────────┐  │
    │  │ Primary │→ │ Replica  │  │
    │  │ (write) │  │ (read)   │  │
    │  └─────────┘  └──────────┘  │
    └─────────────────────────────┘

Data Flow:
  WRITE: App → ProxySQL → MySQL Primary → replicates → MySQL Replica
  READ:  App → Redis (cache hit?) → miss → ProxySQL → MySQL Replica
  INDEX: App → Elasticsearch (after write to MySQL)
  SEARCH: App → Elasticsearch → return IDs → App → Redis/MySQL for details

Step 1: Launch the Complete Infrastructure

📸 Verified Output:


Step 2: Configure MySQL Replication

📸 Verified Output:


Step 3: Create Application Schema

📸 Verified Output:


📸 Verified Output:


Step 5: Build the Full Data Flow — Write Path

📸 Verified Output:


Step 6: Verify Data Consistency Across All Systems

📸 Verified Output:


Step 7: High-Availability Test — Primary Failover

📸 Verified Output:


Step 8: Capstone Summary — Architecture Evaluation

📸 Verified Output:


Final Architecture Summary

Layer
Technology
Purpose
Covered In

Primary DB

MySQL 8.0 Primary

Authoritative writes, ACID

Labs 01, 03, 06-09

Replication

MySQL Replica

Read scaling, failover

Labs 01-03

Connection Pooling

ProxySQL

Read/write splitting, pooling

Lab 10

Cache

Redis

Sub-millisecond hot data

Lab 17

Search

Elasticsearch

Full-text, aggregations

Lab 19

Time-series

Cassandra

IoT, events (optional)

Lab 18

Document DB

MongoDB

Flexible schema (optional)

Labs 15-16

Production Readiness Checklist

Last updated