Skip to content

About

Production-inspired, hands-on learning repository that explores MySQL 8 high availability concepts from first principles

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MySQL8SourceReplicaLab

What this repository is

This repository is a sequence of production-style subprojects that teach MySQL replication and availability step by step. Each subproject builds on the previous one and focuses on one major concept at a time.

Learning path

  • SubProject01 — Single MySQL CRUD
  • SubProject02 — Multiple MySQL servers
  • SubProject03 — Asynchronous source-replica replication
  • SubProject04 — Semi-synchronous replication
  • SubProject05 — GTID-based replication
  • SubProject06 — Manual failover
  • SubProject07 — Automatic failover

Why this repository exists

Most replication tutorials stop after setting up a replica.

This repository goes further by showing:

  • how replication works,
  • how semi-sync changes commit behavior,
  • how GTID simplifies recovery,
  • how to handle source failure manually,
  • and how to automate failover.

Common design pattern

Across the repository, the following ideas are reused:

  • FastAPI as the application layer
  • MySQL 8 as the database layer
  • Docker and Docker Compose for local infrastructure
  • Shell scripts for step-by-step setup
  • Explicit verification scripts after each major change

Database roles

Typical topology:

  • mysql_db_write_1 — source or primary
  • mysql_db_read_1 — replica or promoted primary depending on the project

Application behavior

FastAPI typically exposes:

  • POST /orders for write operations
  • GET /orders for read operations

Writes go to the writable database. Reads go to the replica unless the topology changes during failover.

What you will learn

  • How MySQL binary logs work
  • How replication threads work
  • How GTID changes replication recovery
  • How semi-sync improves durability
  • How to promote a replica manually
  • How to automate failover using Python and Docker
  • How application configuration must change during database promotion

How to use the repository

  1. Start the Docker environment for the subproject you want to study.
  2. Run the scripts in order.
  3. Test the FastAPI APIs.
  4. Simulate failures where applicable.
  5. Observe how the system behaves and recovers.

Suggested workflow

For each subproject:

  • read the README first,
  • run the scripts one by one,
  • verify the output,
  • and only then move to the next subproject.

Final note

This repository is designed as a step-by-step learning lab. The intention is not just to configure replication, but to understand the operational behavior of MySQL replication systems from first principles.

About

Production-inspired, hands-on learning repository that explores MySQL 8 high availability concepts from first principles

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages