Backend Development 9 min read

Understanding Service Gateways: Architecture, Benefits, and Technical Choices

This article explains what a service gateway is, why it is needed in micro‑service architectures, outlines its core functions such as routing and filtering, discusses deployment considerations, and presents a practical technology stack including Spring Boot, Zuul, Consul, JWT, Prometheus, and ELK.

Top Architect
Top Architect
Top Architect
Understanding Service Gateways: Architecture, Benefits, and Technical Choices

What is a Service Gateway

A service gateway combines routing and filtering, acting as the entry point for all external requests and forwarding them to backend micro‑services.

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

Why a Service Gateway is Needed

Placing cross‑cutting concerns such as permission validation, rate limiting, and monitoring in the gateway avoids duplicating code in each service, reduces JAR size, and simplifies upgrades because changes are made only in the gateway filters.

Placement of Permission Validation

Each service implements it individually (inefficient).

A shared library is used by all services (increases JAR size and complicates upgrades).

The gateway’s pre‑filter handles it centrally (recommended).

Technical Selection

Typical stack: Java + Groovy (dynamic filter addition), Spring Boot as the micro‑service framework, Netflix Zuul as the gateway component, Consul for service registration, JWT for authentication, Prometheus + Grafana for monitoring, Logback + ELK for unified logging, and JMeter for load testing.

Gateway Architecture Overview

When the system starts, the gateway, open‑service, and individual services register themselves with the service registry. Users send requests to the gateway, which performs intelligent routing, permission checks, monitoring, and rate limiting before forwarding to open‑service, which aggregates responses from internal services and returns them to the gateway and finally to the user.

Key Functions of the Gateway

Intelligent routing: forwards external requests to appropriate services.

Permission validation: checks user access only for external calls.

API monitoring: tracks gateway traffic and performance metrics.

Rate limiting: works together with monitoring to control traffic.

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

Additional Considerations

The gateway introduces an extra hop, slightly affecting performance, but a well‑provisioned gateway machine (or fronting Nginx) mitigates this. Avoid making the gateway a single point of failure by scaling horizontally or placing a high‑performance Nginx in front of it.

backend architecturemicroservicesroutingSpringBootFiltersZuulservice 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.