Post

Envoy Proxy: A Comprehensive Introduction to Architecture, Use Cases, and Practical Deployment

Envoy Proxy: A Comprehensive Introduction to Architecture, Use Cases, and Practical Deployment

Abstract

In the rapidly evolving landscape of cloud-native computing, service-to-service communication is becoming increasingly complex. Reliability, observability, scalability, and security are no longer optional; they are fundamental requirements. Traditional network proxies, while effective for their time, struggle to meet the dynamic demands of modern distributed systems. Enter Envoy Proxy, a high-performance, extensible, and cloud-native edge and service proxy designed to bridge this gap.

This article provides a comprehensive overview of Envoy. We delve into its architecture, primary use cases, and situate it within the broader ecosystem by comparing it with contemporary alternatives. Practical examples based on containerized deployments are provided to facilitate hands-on experience. Our aim is to provide both theoretical understanding and practical skills for deploying Envoy in real-world scenarios.


1. Introduction

The advent of microservices architecture has revolutionized software development by promoting modularity, scalability, and independent deployment. However, this granularity introduces new challenges, particularly in networking:

  • How do services discover each other?
  • How can we monitor service health and communication latency?
  • How do we enforce security policies across communication channels?
  • How do we implement resilient communication patterns like retries, timeouts, and circuit breaking?

Traditional proxies like Nginx and HAProxy, while effective in monolithic or static environments, are ill-equipped to handle the dynamism and scale of microservices architectures.

To address these challenges, Lyft engineers initiated the development of Envoy Proxy in 2016, driven by the necessity for a robust, dynamic, and extensible proxy that could handle modern networking complexities. Envoy’s success has led to its adoption by numerous major organizations and its graduation as a project within the Cloud Native Computing Foundation (CNCF), joining other cloud-native titans like Kubernetes and Prometheus.

This article seeks to explain why Envoy has become a backbone in modern systems and to offer a clear pathway for newcomers to learn and apply it.


2. What is Envoy Proxy?

Envoy Proxy is an open-source Layer 7 proxy and communication bus designed for modern microservices architectures. Its design goals include:

  • High performance: Written in C++ with an emphasis on efficiency.
  • First-class observability: Metrics, distributed tracing, and logging are integral.
  • Dynamic configuration: Adaptation to changing environments without restarts.
  • Extensibility: Modular filter chains and WebAssembly (Wasm) support.

2.1 Architectural Overview

Envoy is often described as a universal data plane. It operates at two logical levels:

  • Data Plane: Handles the actual data forwarding, load balancing, encryption, retries, and health checking.
  • Control Plane: Provides dynamic configuration of listeners, clusters, and routes through standardized APIs (xDS).

Unlike traditional proxies that require static configuration files, Envoy can ingest dynamic configurations from external control planes like Istio’s Istiod, Contour, or Gloo Mesh.

Its core concepts include:

  • Listeners: Bind to IP addresses and ports and define how incoming connections are handled.
  • Clusters: Abstract groups of endpoints (e.g., application instances).
  • Routes: Define how requests are matched and forwarded to clusters.
  • Filters: Modular components in the request/response path, offering capabilities like authentication, rate limiting, and observability.

Envoy’s architecture makes it ideal for use as an ingress proxy, service mesh data plane, or even an API gateway.


3. Key Features of Envoy

To appreciate Envoy’s capabilities, it’s critical to understand its key features:

3.1 Dynamic Service Discovery

Envoy natively supports service discovery via DNS resolution or through integration with service discovery systems like Consul or Kubernetes. More sophisticated deployments leverage the xDS APIs to dynamically update cluster membership without restarting Envoy.

3.2 Advanced Load Balancing

Envoy implements multiple load balancing algorithms:

  • Round Robin
  • Random
  • Least Request (ideal for low-latency workloads)
  • Maglev Hashing (useful for distributed systems needing consistent hashing)

Additionally, outlier detection can eject misbehaving hosts from the load balancing pool, improving service reliability.

3.3 Observability

Envoy provides detailed metrics via its admin endpoint and exposes native support for tracing frameworks like:

  • Jaeger
  • Zipkin
  • Datadog

Every aspect of communication — from connection time to response size — can be measured and monitored, facilitating fine-grained observability.

3.4 Security Features

  • TLS/mTLS termination
  • SNI (Server Name Indication) support
  • Rate limiting
  • JWT authentication

With the growing emphasis on zero-trust architectures, Envoy’s capabilities are increasingly critical in production environments.

3.5 Extensibility

Envoy is built around a filter chain model, allowing for dynamic extension of functionality without modifying the core code. Additionally, the Wasm (WebAssembly) runtime enables the development of lightweight, efficient plugins in languages like Rust or C++.


4. Common Use Cases

Given its design, Envoy is suitable for a variety of use cases:

4.1 Edge Proxy

As an edge proxy, Envoy manages traffic between the outside world and your cluster. It handles:

  • TLS termination
  • Load balancing across services
  • Path-based routing
  • Rate limiting to prevent abuse

It can replace traditional reverse proxies like Nginx or HAProxy while providing more dynamic behavior.

4.2 Service Mesh Data Plane

In service mesh architectures, every service is accompanied by an Envoy sidecar proxy, forming a data plane responsible for traffic control. Popular service mesh implementations like Istio, Consul Connect, and AWS App Mesh rely on Envoy for:

  • Secure communication (mTLS)
  • Traffic shifting (canary deployments, A/B testing)
  • Policy enforcement (authorization, rate limiting)
  • Observability and telemetry

4.3 API Gateway

While not a full-fledged API gateway, Envoy can act as a lightweight gateway layer with basic authentication, routing, and transformation capabilities. It can be enhanced with third-party control planes to handle more complex scenarios.

4.4 Layer 4/7 Load Balancer

Unlike traditional Layer 4 TCP load balancers, Envoy can load balance at both Layer 4 and Layer 7, enabling fine-grained traffic management based on headers, paths, and more.


5. Alternatives to Envoy

While Envoy is powerful, it is not the only tool in the ecosystem. Below is a detailed comparison:

ProxyDesigned ForStrengthsLimitations
NginxWeb server, reverse proxyHigh performance, SSL termination, cachingStatic configuration, lacks dynamic service discovery
HAProxyTCP/HTTP load balancingProven performance, reliabilityLimited Layer 7 support, complex configs
TraefikDynamic reverse proxy, microservicesKubernetes-native, automatic discoveryLimited extensibility, less granular control
KongAPI GatewayPlugin ecosystem, API security and managementFocused on APIs, less suitable for general proxying
Istio (Envoy-based)Service meshFull service mesh capabilitiesSteep operational complexity, resource-intensive

Envoy vs Nginx: Nginx shines in static web hosting and simple reverse proxying, but Envoy offers dynamic configuration and deeper observability.

Envoy vs HAProxy: HAProxy excels in L4 load balancing, while Envoy provides more comprehensive L7 features.

Envoy vs Traefik: Traefik is easier for Kubernetes beginners; Envoy is more feature-rich for complex traffic policies.


6. Practical Guide: Deploying Envoy with Docker

Let’s transition from theory to practice by deploying Envoy in a containerized environment.

6.1 Prerequisites

  • Docker installed
  • Basic familiarity with YAML and networking

6.2 Writing a Minimal Configuration

Create a file called envoy.yaml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address: { address: 0.0.0.0, port_value: 8080 }
      filter_chains:
        - filters:
            - name: envoy.filters.network.http_connection_manager
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
                stat_prefix: ingress_http
                route_config:
                  name: local_route
                  virtual_hosts:
                    - name: local_service
                      domains: ["*"]
                      routes:
                        - match: { prefix: "/" }
                          route:
                            cluster: service_backend
                http_filters:
                  - name: envoy.filters.http.router
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
    - name: service_backend
      connect_timeout: 5s
      type: logical_dns
      lb_policy: round_robin
      load_assignment:
        cluster_name: service_backend
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: httpbin.org
                      port_value: 80
admin:
  access_log_path: /tmp/admin_access.log
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901

6.3 Running Envoy

Launch Envoy in a Docker container:

1
2
3
4
docker run --rm -d --name envoy \
  -p 8080:8080 -p 9901:9901 \
  -v $(pwd)/envoy.yaml:/etc/envoy/envoy.yaml \
  envoyproxy/envoy:v1.34.1

Verify it is running by sending a request:

1
curl http://localhost:8080/get

This forwards the request to httpbin.org.

6.4 Admin Interface

Envoy provides an admin interface on port 9901. Access it via:

1
curl http://localhost:9901/server_info

This endpoint provides detailed runtime information about the proxy.


7. Advanced Configurations

Once comfortable with basic deployments, users can extend their Envoy usage:

7.1 Health Checking

Configure active health checks to ensure traffic is only sent to healthy upstreams:

1
2
3
4
5
6
7
health_checks:
  - timeout: 1s
    interval: 5s
    unhealthy_threshold: 2
    healthy_threshold: 2
    http_health_check:
      path: /status

7.2 Mutual TLS (mTLS)

Secure traffic between services with mTLS:

1
2
3
4
5
6
7
8
transport_socket:
  name: envoy.transport_sockets.tls
  typed_config:
    "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
    common_tls_context:
      tls_certificates:
        certificate_chain: { filename: "/etc/envoy/certs/server.crt" }
        private_key: { filename: "/etc/envoy/certs/server.key" }

This ensures that communication is encrypted and authenticated.

7.3 Dynamic Configuration (xDS APIs)

Envoy supports dynamic reconfiguration without downtime using xDS:

  • LDS (Listener Discovery Service)
  • RDS (Route Discovery Service)
  • CDS (Cluster Discovery Service)
  • EDS (Endpoint Discovery Service)

These APIs enable fully automated, real-time updates, critical for large-scale systems.


8. Observability and Telemetry

Envoy is built for observability from the ground up.

8.1 Metrics

Expose metrics for Prometheus scraping at:

1
http://localhost:9901/stats/prometheus

These metrics can be visualized in Grafana dashboards for real-time insights.

8.2 Distributed Tracing

Enable tracing in the Envoy configuration:

1
2
3
4
5
6
7
tracing:
  http:
    name: envoy.tracers.zipkin
    typed_config:
      "@type": type.googleapis.com/envoy.config.trace.v2.ZipkinConfig
      collector_cluster: zipkin
      collector_endpoint: "/api/v2/spans"

Tracing provides valuable visibility into request flow across microservices.


9. Conclusion

Envoy has transformed how service communication is managed in cloud-native architectures. Its emphasis on high performance, observability, extensibility, and dynamic configuration make it uniquely suited for today’s complex systems.

By starting with a simple containerized setup and progressively exploring more advanced configurations like health checking, mTLS, and dynamic updates, users can leverage Envoy’s full potential.

As microservices architectures grow in complexity, proxies like Envoy will become even more critical, underpinning secure, observable, and resilient service meshes and edge proxies.


References

  1. Envoy Proxy Documentation
  2. Matt Klein, 5 years of Envoy OSS
  3. CNCF, “Envoy Graduation Announcement,” 2018.
  4. Understanding xDS APIs
  5. Service Mesh Interface (SMI) Specifications
This post is licensed under CC BY 4.0 by the author.