Skip to content
IT glossary
ArchitectureUpdated December 3, 2026

Sidecar pattern

Sidecar

This pattern runs a helper alongside each application instance. The helper handles a supporting task, such as shipping logs or proxying requests, so that task stays out of the application’s business logic.

What makes a helper a sidecar?

A sidecar belongs to a particular application instance. If you run ten copies of the app, you normally run ten copies of the helper, one next to each app. That pairing is what distinguishes a sidecar from a shared backend. The helper runs outside the application process, which lets teams reuse it across apps written in different languages as long as they agree on how to communicate.

How it works in Kubernetes

The usual setup is two containers in one Pod. They share a network namespace, so one container can call the other on localhost. They also share the same port space: two processes cannot both bind to the same local address and port. To exchange files, the containers can mount the same volume; being in the same Pod does not automatically give them access to each other’s filesystems.

The app and helper can have separate images and resource limits, but the Pod is their unit of placement and scaling. Updating the helper image in a Deployment’s Pod template rolls out replacement Pods, including new app containers. The pattern itself is not Kubernetes-specific: the helper can also run as a separate process managed alongside the app.

Example: shipping file-based logs

Suppose a legacy app writes to /logs/app.log and cannot send logs to a central collector. Mount an emptyDir volume at /logs in both containers. The app writes as before, while the sidecar follows the file and forwards new entries. The volume survives a container restart within the Pod, but deleting the Pod deletes the volume. If the sidecar has not shipped the last batch, those entries can be lost. If the app already logs to standard output and the platform collects those logs from each node, a per-Pod helper may not be worth running.

Trade-offs and interview questions

A common system design question is: “Would you use a library, a sidecar, or a shared service?” A library runs in-process, so there is no extra process to manage, but it needs to be integrated into the app. A shared service can scale independently, but it cannot simply read an app replica’s local files. A sidecar makes sense when the helper needs local access or when every replica needs its own copy.

A service mesh proxy is another example: it can handle traffic and mutual TLS for one workload replica. Unlike an API gateway, which commonly provides a shared entry point for clients, that proxy is attached to the workload. In an interview, explain what happens when the helper fails. A failed log shipper might delay delivery without stopping the app, whereas a failed proxy on the request path can interrupt traffic even while the app process is still running. Also account for the CPU and memory cost of running a helper in every replica.