🔧 DevOps

Envoy

Envoy Proxy

A cloud-native proxy. The data plane of Istio.

Detailed Explanation

Envoy is a high-performance L7 (application layer) proxy developed at Lyft and is now a CNCF graduated project. It handles service-to-service communication in microservice architectures and is widely used as the data plane of service meshes such as Istio and AWS App Mesh.

Key features

  • L7 proxy: supports application protocols such as HTTP/2, gRPC, and WebSocket
  • Dynamic configuration: change configuration at runtime through the xDS API (no restart needed)
  • Observability: detailed metrics, distributed tracing, structured logging
  • Load balancing: Round Robin, Least Connections, Ring Hash, etc.
  • Circuit breaker: isolates failing services to prevent cascading failures
  • TLS termination/origination: supports mutual TLS (mTLS)

Envoy architecture

  • Listener: an endpoint that receives downstream connections
  • Filter Chain: a request/response processing pipeline
  • Cluster: a group of upstream services
  • Route: maps requests to the appropriate cluster

Code Example

envoy.yaml - basic proxy configuration

# envoy.yaml - HTTP 리버스 프록시 설정
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
                codec_type: AUTO
                route_config:
                  name: local_route
                  virtual_hosts:
                    - name: backend
                      domains: ["*"]
                      routes:
                        # API 라우트
                        - match:
                            prefix: "/api/"
                          route:
                            cluster: api_service
                            timeout: 30s
                        # 정적 파일
                        - match:
                            prefix: "/"
                          route:
                            cluster: frontend_service
                http_filters:
                  - name: envoy.filters.http.router
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

  clusters:
    - name: api_service
      connect_timeout: 5s
      type: STRICT_DNS
      lb_policy: ROUND_ROBIN
      load_assignment:
        cluster_name: api_service
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: api-server
                      port_value: 3000
      # 헬스체크
      health_checks:
        - timeout: 3s
          interval: 10s
          unhealthy_threshold: 3
          healthy_threshold: 2
          http_health_check:
            path: /health
      # 서킷 브레이커
      circuit_breakers:
        thresholds:
          - priority: DEFAULT
            max_connections: 1000
            max_pending_requests: 1000
            max_requests: 1000
            max_retries: 3

    - name: frontend_service
      connect_timeout: 5s
      type: STRICT_DNS
      lb_policy: ROUND_ROBIN
      load_assignment:
        cluster_name: frontend_service
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: frontend
                      port_value: 80

admin:
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901

Rate limiting configuration

# Rate limit 필터 설정
http_filters:
  - name: envoy.filters.http.ratelimit
    typed_config:
      "@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit
      domain: my_domain
      stage: 0
      rate_limit_service:
        grpc_service:
          envoy_grpc:
            cluster_name: ratelimit_service
        transport_api_version: V3
  - name: envoy.filters.http.router

# Route level rate limit
routes:
  - match:
      prefix: "/api/"
    route:
      cluster: api_service
      rate_limits:
        - actions:
            - request_headers:
                header_name: "x-api-key"
                descriptor_key: "api_key"

mTLS configuration

# TLS 리스너 설정
filter_chains:
  - filter_chain_match: {}
    transport_socket:
      name: envoy.transport_sockets.tls
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
        require_client_certificate: true
        common_tls_context:
          tls_certificates:
            - certificate_chain:
                filename: /etc/certs/server.crt
              private_key:
                filename: /etc/certs/server.key
          validation_context:
            trusted_ca:
              filename: /etc/certs/ca.crt

Practical Conversation Example

Backend developer
"Since we adopted Istio, there's something called a sidecar proxy. Is that Envoy?"
Infrastructure engineer
"Right. Istio injects Envoy as a sidecar and intercepts all traffic between services. You can apply mTLS encryption, traffic observation, and routing policies without changing service code."
Backend developer
"But a sidecar is attached to every pod, so I'm worried about the resource overhead."
Infrastructure engineer
"Each Envoy typically uses about 50-100MB of memory and adds 10-50ms of latency. For performance-sensitive services, you can adjust resource limits, and more recently there are also approaches that use a shared proxy per node without sidecars (Cilium, Ambient Mesh)."

Cautions

Configuration complexity

Envoy YAML configuration is very complex. Rather than writing it by hand, use higher-level tools such as Istio or Contour, or use an xDS control plane.

Resource overhead

Deploying with the sidecar pattern requires additional memory/CPU per pod. Plan resources carefully in large clusters.

Difficult debugging

Adding a proxy layer makes debugging network problems more complex. Learn how to use the Envoy admin API and detailed logging.

Version compatibility

Watch the xDS API version (v2, v3). Recent Envoy versions may not support v2.

Learn More