Ndërtimi i mirë i mikroshërbimeve kërkon zgjidhjen e sfidave të sistemeve të shpërndarë përmes modeleve të vendosur — për komunikimin e shërbimeve, menaxhimin e të dhënave, reziliencën dhe vëzhgueshmërinë. Këta modele ndihmojnë në menaxhimin e kompleksitetit të brendshëm të mikroshërbimeve.
Modelet e komunikimit dhe API
✓ API GATEWAY → single entry point; centralizes cross-cutting concerns (routing, auth, etc.)
✓ SERVICE DISCOVERY → services find each other dynamically (registry) as instances change
✓ Sync (REST/gRPC) for request/response; ASYNC (events/queues) for decoupling → prefer
async/events to reduce coupling where possible
✓ BFF (Backend for Frontend) → tailored gateways per client type
Modelet e menaxhimit të të dhënave
✓ DATABASE PER SERVICE → each service owns its data (no shared database) → independence,
but data is distributed (no cross-service joins/transactions)
✓ SAGA → manage transactions ACROSS services without distributed transactions:
→ a sequence of local transactions + compensating actions on failure (eventual consistency)
✓ EVENT SOURCING / CQRS → event-based state and separate read/write models
✓ Eventual consistency across services (embrace it; avoid distributed transactions)
