Plan
1. Users
- Visitor Users (readers) → access the site to view content (GET).
- Logged-In Users (editors) → access the panel/app to create or modify content (POST, PUT, DELETE).
2. Servers
- WEB Server (read)
- Serves visitors.
- Runs Nginx/PHP.
- When data is needed, performs read-only (SELECT) queries against the Replica Database.
- APP Server (write)
- Serves logged-in users.
- Runs Nginx/PHP.
- Performs write operations (INSERT/UPDATE/DELETE) on the Primary Database.
3. Database
- Primary MySQL (WRITE)
- Holds N databases, one per domain (
db_site1
, db_site2
, …).
- All writes go here.
- Streams changes in real time to the replica.
- Replica MySQL (READ)
- Exact copy of the primary.
- Also has N databases (
db_site1
, db_site2
, …).
- Continuously updated via replication.
- Responds to visitor read queries.
4. Full Flow
- Visitor → WEB → Replica (SELECT).
- Logged-in User → APP → Primary (INSERT/UPDATE/DELETE).
- Primary → Replica: changes copied immediately (milliseconds/seconds).
👉 Result: