What is Sidecar Pattern?
As per this pattern supporting features of the application are deployed as separate process or container to provide isolation and encapsulation.
This sidecar pattern is often used with containers and referred to as a sidecar container or sidekick container.
This pattern is named Sidecar because it resembles a sidecar attached to a motorcycle.
The sidecar also shares the same lifecycle as the parent application, being created and killed alongside the parent.
What is the problem context?
- Applications generally require additional functionalities like
- Such functionalities tightly integrated, so
- Outage in one of these components can affect other components or the entire application.
- Functionalities need to be implemented using the same language as the parent application.
What is the solution?
The solution is a sidecar pattern:
- Additional functionalities implemented as separate components or services.
- Application is decomposed into services.
- Sidecar services are not necessary part of application but are connected to it.
- Shares the same fate as parent application.
- For each instance of the application, an instance of the sidecar is deployed and hosted alongside it.
What are the advantages of using this pattern?
- Sidecar is independent from its primary application in terms
- Runtime environment
- Programming language
- Proximity to the primary application, hence no significant latency when communicating between them.
- For legacy applications where extending application functionality is difficult, you can use a sidecar to extend functionality.