Search code examples
distributed-computing

Does sidecar topology has to be one to one?


I am trying to learn sidecar pattern in the single-node patterns (which is used for implementing proxies, resource logging, etc.) for distributed systems.

enter image description here enter image description here

I was just wondering if it has anything to do with the cardinality ratios in classes. Does the sidecar to application container have to be one-to-one always?

[ Reference and the images from Designing Distributed by Systems Brendan Burns ]


Solution

  • In general, for enhancing the functionality of the main container, the sidecar container is added. They are light weight supporting processes or services that are usually deployed with the main application.

    A sidecar is used mainly for performing peripheral operations mostly without the knowledge of application container. It shall be mostly sharing the same volume, namespace etc as that of main container. It shall be a container that runs on the same pod as the application container.

    Based on requirement, it shall help in taking care of peripheral functionalities like performing updates, platform abstraction, interservice communications, monitoring or security‑related handlers on behalf of main container.

    Sidecar shall be wherever the main application is present and it's lifecycle is tightly coupled to the main application container. Just as how each motorcycle can have its own sidecar to meet its additional requirement, for each instance of the application, an instance of the sidecar is deployed alongside it for additional peripheral requirements. In general, the sidecar container shall be designed to be small, pluggable and less complex. Hence, it is predominately one to one with main application.

    In case if the sidecar service involves more ipc with main application, it is preferred for having the logic to be part of main application which in turn is based on your requirement. Also, if the sidecar gets bloated or increasingly complex and if it has to scale independently from the main application, then it shall be made an independent service rather than sidecar.