Distributed Systems
Jalex Chang
2019.05.17
The Sidecar Pattern
Jalex Chang
- Backend Engineer @ Umbo Computer Vision
- Taiwan Data Engineering Association Member
- Golang Taiwan Member
- Introduction to the sidecar pattern
- A few case study in Umbo CV
- Conclusion
References
[1] Designing Distributed Systems, https://www.amazon.com/Designing-Distributed-Systems-Patterns-Paradigms-ebook/dp/B079YTM4FC
[2] Sidecar Pattern with Use Case Examples, https://medium.com/@dwdraju/sidecar-pattern-with-use-case-examples-ed6642e5eaf7
Agenda
The sidecar
A sidecar is a one-wheeled device attached to the side of a motorcycle. (Wiki)
The sidecar pattern in Microservices
Advantages
-
Keep application logic intact and maintainable
-
Carry on extra trivial tasks
-
Simplify the complexity of service design
-
-
Secure or access control of the application service
-
Network traffic filtering
-
Protocol transfer
-
e.g. Redis's in-transit encryption
-
-
-
Reusability of components
-
Common logic is reusable across similar application services
-
-
Explicit service boundary
-
Programming language separating
-
Use cases
-
Adapt legacy applications
-
Modularity and reuse of the components
-
Configuration synchronization
-
Automatic service update
- TLS/SSL termination
- Circuit breaking, routing, and monitoring
- Log collector
- Proxy and caching
Sidecar Example 1
Adding HTTPS to a legacy service
Sidecar Example 2
Configuration synchronization
Camera config caching service
Case study in Umbo CV
There are too many RESTful API calls querying camera configurations from our CV pipeline and video streaming services ......
-
Actually, camera info would not be changed frequently.
- But, we still want our services to get updates asap.
CornerBear is born
CornerBear is a sidecar caching service for Media Server and CV Router aims to help them manage cameras' info and notify changes for registered events.
Even a sidecar, we still need to design its architecture strictly.
Service log collector
Case study in Umbo CV
Network is unreliable
You have no idea what a network request may meet during its journey.
If services fail to log, should they handle errors by themselves?
e.g. Retry sending, message buffering ...etc
Sidecar for log collection
- Apply Fluentd as a sidecar logger collector.
- Event-based, interval flushing, and autonomy.
Principles of the sidecar design
To be successful, a sidecar should be simple but flexible.
-
One sidecar, one goal
-
Modularity and reusability matter
Modularity and Reusability
-
Parameterizing your services
-
Configure them through environment variables or CLI
-
-
Define the compatible API surface
-
In microservices, API is the only way to do service communication.
-
Both backward and forward compatible is important.
-
-
Documenting your services
-
Ensuring developers can use them in the first place.
-
At least, you should provide an API doc or README.
-
What have we learned today?
-
The sidecar motocross is dangerous. -
The sidecar pattern is helpful to reduce system complexity by reusing common logic and abstracting trivial tasks.
-
Service design matters in both performance and maintenance.
-
In Umbo, we are really keen on adopting and practicing state-of-the-art software engineering ways to improve products and our career paths.
Q&A Time
Thanks for listening
Distributed Systems: The Sidecar Pattern
By Jalex Chang
Distributed Systems: The Sidecar Pattern
The sidecar pattern is a useful way to simplify the complexity of system design in microservices. In this talk, the author is going to introduce the sidecar pattern including its concept, benefits, and use cases. Besides, the author will show a few case study in Umbo CV, such as a caching service and a log collector.
- 1,143