Gateway Role & Value

In the evolution of software architecture, the gateway has gradually transformed from an "optional component" into a "core infrastructure." Whether it is an API gateway for internet applications or an industrial gateway for IIoT, the essence is the same: solving the problem of interconnection and coordination between different systems, different protocols, and different networks.

This article explains why gateways are needed, their core functions, and key design considerations from the perspective of software architecture evolution, helping readers understand the critical role of gateways in modern systems.

1. From Monolithic to Microservices: The Background for Gateways

1.1 The Monolithic Era

In the early days, most applications used a monolithic architecture: one application contained all functional modules, and clients called the backend directly via REST APIs.

Workflow:

  • Client (Web/App) → Load balancer → Multiple identical application instances → Database

Problems:

  • Large codebase, difficult to maintain

  • Modifying one function requires redeploying the entire application

  • Poor scalability (only horizontal scaling of the whole application)

  • Technology lock-in (difficult to introduce new languages or frameworks)

1.2 Challenges of Microservices Architecture

Microservices architecture splits a monolithic application into multiple small, autonomous services, each focusing on a specific business function (e.g., orders, users, inventory). While this brings flexibility, it also introduces new problems:

ProblemDescription
Client-API mismatchFine-grained APIs exposed by microservices (e.g., "get user info", "get order list") do not match the aggregated data clients need (e.g., "user info + order list")
Protocol inconsistencyDifferent microservices may use different protocols (HTTP, gRPC, Thrift, AMQP), making direct client calls difficult
Difficult refactoringDirect communication between services means merging or splitting services requires modifying multiple callers
Security risksExposing each service directly to clients increases the attack surface
Duplicate workEvery service must implement authentication, logging, rate limiting, and other common functions

Solution: Introduce a gateway layer between the client and backend services.

2. Core Functions of a Gateway

The gateway sits below the access layer and above the business service layer, serving as the "unified entry point" for all client requests. Its core functions include:

2.1 Request Routing

The gateway receives client requests and forwards them to the appropriate microservice instance based on routing rules (e.g., URL path, request headers). Clients only need to know the gateway address, not the specific locations of backend services.

2.2 Service Registration and Discovery

The gateway dynamically obtains the address list of backend services through a service registry (e.g., Consul, Eureka, Nacos). When service instances come online or go offline, the gateway感知 automatically without manual configuration changes.

2.3 Load Balancing

The gateway distributes requests across multiple service instances, supporting strategies such as:

  • Round robin: Distribute sequentially

  • Weighted distribution: Different weights based on instance performance

  • Least connections: Distribute to the instance with the fewest active connections

  • Session affinity: Always route requests from the same client to the same instance

2.4 Resilience Engineering

The gateway provides fault tolerance when service calls fail:

MechanismFunction
RetryAutomatically retry other instances after a failed request
Circuit breakerTemporarily break the circuit when a service persistently fails, preventing cascading failures
FallbackReturn default values or cached data when a service is unavailable
Rate limitingControl request rates to prevent service overload

2.5 Security Protection

As the unified entry point to the system, the gateway centralizes security tasks:

  • SSL/TLS termination: Decrypts HTTPS requests, reducing load on backend services

  • Authentication: Validates JWT, OAuth tokens, etc.

  • Authorization: Checks whether users have permission to access specific resources

  • Attack prevention: Intercepts malicious requests such as SQL injection, XSS, and DDoS

3. Advanced Gateway Features

Beyond basic functions, modern gateways also support the following advanced features:

3.1 Canary Release (Gray Release)

The gateway routes requests to different versions of service instances based on rules (e.g., specific user IDs, version indicators in request headers). For example: 5% of traffic to the new version, 95% to the old version, gradually increasing to reduce deployment risk.

3.2 API Aggregation

Clients may need to call multiple services to obtain complete data. The gateway can aggregate multiple requests into one:

  • Scenario: A product detail page needs data from three services: "product info", "inventory status", and "user reviews"

  • Gateway action: Call the three services in parallel, aggregate the results, and return them to the client in a single response

Effect: Client requests reduced from 3 to 1, faster response times.

3.3 API Orchestration

The gateway can define the order and logic of a series of API calls to implement complex business processes. For example:

  • Call the "create order" service

  • Call the "deduct inventory" service

  • Call the "send notification" service

  • If a step fails, automatically execute compensation operations

4. Key Design Considerations for Gateways

4.1 High Performance

The gateway sits at the "throat" of the request path, so performance is critical:

  • Use high-performance languages (Go, Java, C++, Rust)

  • Use asynchronous non-blocking I/O models (e.g., Netty, NIO)

  • Avoid heavy business logic in the gateway

4.2 High Availability

If the gateway goes down, all services become unavailable:

  • Multi-instance cluster: At least 2 instances to avoid single point of failure

  • Stateless design: Facilitates horizontal scaling

  • Graceful shutdown: Update without interrupting existing connections

  • Dynamic configuration updates: Modify routing rules without restarting

4.3 High Extensibility

Business requirements change constantly; the gateway should be extensible:

  • Plugin architecture: Add custom functions (e.g., custom authentication, log format) via plugins

  • Programmable: Support scripting languages such as Lua or JavaScript for routing rules

  • Hot loading: Plugin updates without restarting

5. From Software Gateway to Industrial Gateway: The Essence is the Same

Understanding the API gateway in software architecture helps understand the industrial gateway in IIoT. The essential logic of the two is consistent:

DimensionAPI Gateway (Software)Industrial Gateway (IIoT)
Connected entitiesWeb/App client ↔ MicroservicesPLC/sensor ↔ Cloud platform
Protocol conversionHTTP ↔ gRPC/Thrift/AMQPModbus/Profinet ↔ MQTT/HTTP
Data aggregationAggregate data from multiple servicesAggregate data from multiple sensors
Security protectionJWT validation, SSL terminationVPN encryption, firewall
Edge processingRequest filtering, rate limitingData filtering, threshold judgment
Operations monitoringDistributed tracing, performance statsDevice status, signal strength

Core commonality: Gateways solve the problem of interconnection between heterogeneous systems, protocol conversion, security control, and traffic management. Whether for software services or industrial devices, as system scale grows and heterogeneity increases, a gateway becomes an essential middle layer.

6. Conclusion: The Gateway is the "Traffic Hub" of Modern Systems

From monolithic to microservices, from on-premises devices to the cloud, the emergence of gateways is not accidental, but an inevitable choice as system complexity grows beyond a certain point.

The value of a gateway can be summarized as:

  • For clients: Simplified calls, unified entry point, reduced request count

  • For backend services: Isolation protection, load balancing, security filtering

  • For operations teams: Unified monitoring, canary releases, traffic control

When designing or selecting a gateway, focus on the three core metrics of performance, availability, and extensibility. Whether a software API gateway or an industrial gateway, both play the same role in their respective domains — connecting, converting, protecting, and governing. Understanding this is the way to understand "why we need a gateway."

E-Marketplace
Contact Information
Email: marketing@movingcomm.com
WhatsApp: +852 46409121
WeChat: +86-18077905372
Shenzhen Movingcomm Technology Co., Ltd. A trusted partner for network communication devices and solutions
在线表单
邮箱验证
Subscribe
*
Submit
Copyright ©2026 - Shenzhen Movingcomm Technology Co., Ltd
Download Materials