2019.05.17
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
A sidecar is a one-wheeled device attached to the side of a motorcycle. (Wiki)
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
Adapt legacy applications
Modularity and reuse of the components
Configuration synchronization
Automatic service update
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.
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.
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
To be successful, a sidecar should be simple but flexible.
One sidecar, one goal
Modularity and reusability matter
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.
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.