Backend Development 10 min read

Understanding Service Gateways: Definition, Benefits, and Technical Stack

This article explains what a service gateway is, why it is essential for microservice architectures, outlines its core functions such as routing, filtering, authentication, monitoring, and presents a practical Java‑based technical stack including Spring Boot, Zuul, Consul, JWT, Prometheus, ELK and JMeter.

Top Architect
Top Architect
Top Architect
Understanding Service Gateways: Definition, Benefits, and Technical Stack

1. What is a Service Gateway

服务网关 = 路由转发 + 过滤器

1. Routing: receives all external requests and forwards them to backend microservices.

2. Filters: can implement cross‑cutting concerns such as permission checks, rate limiting, monitoring, etc. (Routing itself is also realized via filters.)

2. Why a Service Gateway is Needed

The cross‑cutting functions (e.g., permission validation) can be placed in three locations:

Each service implements it individually.

A shared common service that all microservices depend on.

The gateway’s pre‑filter, where every request is validated once.

Placing the logic in each service leads to duplicated code and larger JARs, especially problematic for Docker images. Using a common service introduces coupling and makes upgrades difficult because every service must be recompiled.

The gateway solves these problems by moving permission logic to its filters, keeping backend services lightweight and allowing centralized updates without redeploying all services.

3. Service Gateway Technical Selection

The architecture after introducing a gateway consists of three parts: the gateway, an open‑service layer, and the actual services.

1. Overall Flow

Gateway, open‑service, and services register themselves with a service registry.

Clients send requests to the gateway, which performs intelligent routing, service discovery, load balancing, permission checks, monitoring, and rate limiting before forwarding to the open‑service.

The open‑service aggregates responses from internal services and returns them to the gateway, which then replies to the client.

2. Considerations When Adding a Gateway

Introducing a gateway adds an extra hop, slightly reducing performance, but the impact is usually small if the gateway machine is powerful.

The gateway can become a single point of failure; a common practice is to place a high‑performance Nginx in front of it or deploy multiple gateway instances on robust hardware.

The gateway should remain lightweight.

3. Basic Functions of a Service Gateway

Intelligent routing: forwards all external requests to the public open‑service.

Permission validation: only validates requests coming from clients, not internal service‑to‑service calls.

API monitoring: tracks requests passing through the gateway and its own performance metrics (e.g., GC).

Rate limiting: works together with monitoring to limit traffic.

Unified API logging: records entry and exit logs similar to an aspect.

... (future extensions)

Additional capabilities such as A/B testing can also be implemented, though the split engine is usually placed in the open‑service rather than the gateway.

4. Chosen Technical Stack

Programming language: Java + Groovy (Groovy allows dynamic addition of filters without restarting the gateway).

Microservice framework: Spring Boot.

Gateway component: Netflix Zuul.

Service registry: Consul.

Permission validation: JWT.

API monitoring: Prometheus + Grafana.

Unified logging: Logback + ELK.

Load testing: JMeter.

... (future extensions)

The author also invites readers to join a community, offers ChatGPT access, and promotes related courses and resources, but these sections are promotional and not part of the technical discussion.

BackendJavaMicroservicesAPI GatewayConsulZuulservice gateway
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.