Course contentsShow
← System Design
Lesson 874 of 1,91923. API Gateway PatternFree lesson

Protocol Translation

Converting between different protocols (HTTP/REST, gRPC, WebSocket) at the gateway layer.

Protocol Translation

What you'll learn: How API Gateways convert between different communication protocols to enable seamless service interaction.

What is Protocol Translation?

Protocol translation is the gateway's ability to translate requests and responses between different communication protocols. Your frontend might speak HTTP/REST, but your backend services could use gRPC for efficiency or WebSockets for real-time updates. The gateway acts as a universal translator, converting between these protocols so clients and services don't need to understand each other's native languages.

Why Translation is Needed

Modern systems often use different protocols for different purposes:

  • HTTP/REST: Simple, browser-friendly, widespread
  • gRPC: High-performance, binary, strongly-typed
  • WebSocket: Bidirectional, real-time streaming

Without translation, your mobile app would need to implement gRPC libraries just to talk to backend services. Your web browser would need custom WebSocket handling for every streaming endpoint. This creates tight coupling and complexity.

How It Works

The gateway sits in the middle and performs bidirectional translation:

Client → Gateway (HTTP) → Gateway translates → Gateway → Service (gRPC)

When the response returns, the gateway reverses the translation:

Service → Gateway (gRPC) → Gateway translates → Gateway → Client (HTTP)

Think of it like an airport translator: tourists speak their native language, locals speak theirs, and the translator ensures both parties understand each other without learning new languages.

Common Translation Scenarios

  • REST API calls converted to gRPC service invocations
  • HTTP polling upgraded to WebSocket streaming
  • Legacy SOAP services exposed as modern REST endpoints
  • External HTTP APIs consumed internally via efficient binary protocols

Key Takeaway: Protocol translation at the gateway enables clients and services to use their optimal protocols without tight coupling, simplifying client implementations while allowing backend services to choose the most efficient communication method.