Envoy
Envoy is a proxy that sits between clients and services. It forwards requests to the right backend, spreads traffic across service instances, and can enforce timeouts and record traffic metrics.
What Envoy does
Envoy is an open-source network proxy that runs separately from application code. A client can connect to Envoy instead of connecting directly to a backend. Envoy decides where to forward the traffic, so the client can use the same address even as backend instances come and go. It can proxy TCP streams or inspect HTTP requests and route them using details such as the host, path, or headers. Its HTTP/2 support lets it handle gRPC traffic at the request level as well.
How a request moves through Envoy
- A listener accepts connections on an address and port. Its filters determine how the connection is handled, for example by passing through TCP traffic or processing HTTP requests.
- For HTTP traffic, a route matches a request and decides what happens next. A forwarding route selects a cluster, which is Envoy's name for a group of upstream backends, not necessarily a Kubernetes cluster.
- A load-balancing policy selects an endpoint, such as a particular backend IP address and port. When active health checks are configured, a failing endpoint can be excluded from normal load balancing.
Envoy can read configuration from a local file or receive updates through the xDS APIs. With xDS, a control plane can publish changes such as new routes or backend addresses while Envoy continues to handle traffic as the data plane. You don't need a separate control plane to run Envoy with static configuration.
Example: rolling out a new version
Suppose /catalog normally goes to a stable version of a service. To try a new version, configure two upstream clusters and assign them weights of 95 and 5. Envoy first chooses the cluster for each matching request, then load-balances within that cluster. Roughly 5% of matching requests go to the new version over time. That is not the same as sending 5% of users to it: keeping a given user on one version requires a routing strategy that preserves that assignment.
Where it fits
Envoy can run at the edge as a reverse proxy for external traffic or next to an application as a sidecar for service-to-service traffic. In a sidecar-based Istio deployment, for example, Envoy handles the traffic and Istio supplies the configuration. Envoy alone is not a service mesh. A proxy adds a hop and consumes resources, so weigh that cost against the value of applying traffic policies consistently and collecting access logs and metrics outside the application.
In an interview
Start by tracing a request from listener to route to cluster to endpoint. Then be ready to explain a policy trade-off. For example, should Envoy retry a timed-out request that creates an order? Not by default: a timeout tells you that a response didn't arrive in time, not that the write failed. Retrying can create a duplicate unless the operation is idempotent, for example because the backend recognizes an idempotency key.