Kodeloka
  1. Kodeloka
  2. Kelas Microservices
  3. Materi

Arsitektur · Modul 3 dari 24

Belajar Microservices - Arsitektur Microservices

Konsep Decomposing aplikasi menjadi layanan-layanan independen, prinsip High Cohesion & Loose Coupling, Bounded Context (Domain-Driven Design), dan siklus rilis mandiri.

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 )