Microservices Architecture
1.1 Overview
1.2 Structure of Microservices
The CapsureLabs microservices architecture is divided into several key services, each organized by function:
Manages user data, authentication, and access control.
Each of these services is deployed independently and communicates with other services using secure, well-defined interfaces. The microservices structure is designed to support horizontal scaling, meaning each service can scale independently based on demand.
1.3 Service Communication
Communication between services is handled through two primary mechanisms:
REST is used for standard HTTP communication, providing simple and scalable communication between internal services.
REST API Communication
A common scenario involves the User Service interacting with the NFT Service to fetch a user’s NFT assets. Here’s an example configuration for a REST API-based communication:
User Service Code for Fetching NFTs
gRPC Communication
For high-performance communication, CapsureLabs uses gRPC. In this example, the Trading Service sends real-time market data to the Analytics Service using gRPC.
Trading Service Code for Sending Market Data via gRPC
Define gRPC Protocol (market.proto
)
market.proto
)Trading Service Client Implementation
In this example, Trading Service sends market data to the Analytics Service via gRPC, providing a low-latency communication path for real-time updates.
1.4 Service Discovery and Load Balancing
To ensure that services can dynamically locate and communicate with each other, CapsureLabs employs a service discovery mechanism. This mechanism uses a registry where services register themselves upon startup, and other services can query this registry to locate the necessary endpoints. This registry enables load balancing and supports scaling up instances of high-demand services.
For service discovery and health checks.
1.5 Data Management and Persistence
Each microservice is responsible for managing its own data and database. This design follows the database-per-service pattern, which isolates each service’s data to reduce dependencies. For shared data, each service either directly queries or requests access from the data-owning service.
1.6 Error Handling and Resilience
To ensure that the system remains stable, CapsureLabs implements
Circuit breaker patterns prevent cascading failures by monitoring service health and disabling calls to failing services.
Last updated