0
0
Microservicessystem_design~12 mins

Sidecar pattern in Microservices - Architecture Diagram

Choose your learning style9 modes available
System Overview - Sidecar pattern

The Sidecar pattern is used in microservices to add extra features like logging, monitoring, or configuration without changing the main service code. It runs alongside the main service in a separate process or container, helping keep the service simple and focused.

Architecture Diagram
User
  |
  v
+-----------------+       +-----------------+
|   Main Service  |<----->|   Sidecar Proxy  |
+-----------------+       +-----------------+
          |                        |
          v                        v
    +------------+           +------------+
    |  Database  |           |  Logging   |
    +------------+           +------------+
Components
User
client
Sends requests to the main service
Main Service
service
Handles core business logic and processes user requests
Sidecar Proxy
sidecar
Runs alongside the main service to provide additional features like logging, monitoring, or configuration
Database
database
Stores persistent data for the main service
Logging
service
Collects and manages logs sent from the sidecar proxy
Request Flow - 5 Hops
UserMain Service
Main ServiceSidecar Proxy
Main ServiceDatabase
Sidecar ProxyLogging
Main ServiceUser
Failure Scenario
Component Fails:Sidecar Proxy
Impact:Additional features like logging and monitoring stop working, but main service continues to handle requests normally.
Mitigation:Main service is designed to work independently; sidecar can be restarted or replaced without affecting core functionality.
Architecture Quiz - 3 Questions
Test your understanding
What is the main purpose of the Sidecar Proxy in this architecture?
ATo provide additional features like logging and monitoring
BTo handle core business logic
CTo store persistent data
DTo serve user requests directly
Design Principle
The Sidecar pattern separates auxiliary tasks from the main service by running them in a parallel process or container. This keeps the main service simple and focused, while the sidecar handles cross-cutting concerns like logging and monitoring without changing the service code.