1. Prinsip Utama Pemecahan Service
Kunci sukses arsitektur Microservices terletak pada penerapan Domain-Driven Design (DDD) untuk menentukan batas-batas wilayah tanggung jawab setiap service (Bounded Context).
- High Cohesion: Seluruh fungsi dan data yang berkaitan erat dikelompokkan bersama di dalam 1 service yang sama.
- Loose Coupling: Setiap service tidak bergantung pada implementasi internal service lain. Perubahan di Service A tidak boleh mewajibkan perubahan kode di Service B.
2. Perbandingan Monolith vs Microservices Architecture
Struktur Perbandingan Arsitektur
[ MONOLITH ARCHITECTURE ]
Client ---> [ API Gateway / Load Balancer ]
│
▼
┌──────────────────────────────┐
│ Monolith Application │
│ ├── Auth Module │
│ ├── Order Module │
│ ├── Inventory Module │
│ └── Payment Module │
└──────────────┬───────────────┘
│
▼
┌────────────────┐
│ Shared RDBMS │
└────────────────┘
----------------------------------------------------
[ MICROSERVICES ARCHITECTURE ]
Client ---> [ API Gateway Router ]
├──> [ Auth Service ] ──────> ( Auth DB )
├──> [ Order Service ] ─────> ( Order DB )
├──> [ Inventory Service ] ─> ( Inventory DB )
└──> [ Payment Service ] ───> ( Payment DB )