Service Gateway Explained: Routing, Filters, Benefits, and Java‑Based Technical Stack

This article explains what a service gateway is—combining routing and filters—covers why it is needed for centralized cross‑cutting concerns such as authentication, rate limiting and monitoring, describes the architecture and request flow with gateway, open‑service and microservices, and recommends a Java‑based stack including Spring Boot, Netflix Zuul, Consul, JWT, Prometheus, Grafana, ELK and JMeter.

Top Architect
Top Architect
Top Architect
Service Gateway Explained: Routing, Filters, Benefits, and Java‑Based Technical Stack

What is a Service Gateway? The author defines a service gateway as the combination of routing and filters: 服务网关 = 路由转发 + 过滤器. Routing forwards all external requests to backend micro‑services, while filters implement cross‑cutting functions such as authentication, rate limiting, and monitoring.

Why a Service Gateway? Authentication can be placed in three locations: (1) each service implements it individually (high duplication, rarely used), (2) a shared library that each service depends on (increases JAR size and complicates upgrades), and (3) a pre‑filter in the gateway (centralizes logic, reduces JAR size, simplifies updates).

Architecture after Adding a Gateway The system consists of three parts: the service gateway, an open‑service layer, and the actual services. All components register with a service registry (e.g., Consul). Users send requests to the gateway, which performs intelligent routing, authentication, monitoring, and rate limiting, then forwards to the open‑service that aggregates responses from the underlying services.

Overall Request Flow 1) Services, open‑service, and gateway register to the registry. 2) User requests hit the gateway, which handles routing, auth, monitoring, and rate limiting, then forwards to open‑service. 3) Open‑service aggregates internal service responses and returns them through the gateway to the user.

Considerations When Introducing a Gateway Adding a gateway introduces an extra hop, slightly increasing latency, but this is usually negligible with a powerful gateway machine and internal network communication. To avoid a single point of failure, a front‑end Nginx can be placed before the gateway. The gateway should remain lightweight.

Basic Functions of a Service Gateway • Intelligent routing: receive all external requests and forward them to the appropriate open‑service. • Authentication: validate user requests at the gateway level. • API monitoring: track gateway traffic and its own performance metrics. • Rate limiting: enforce limits in conjunction with monitoring. • Unified API logging: record entry and exit logs for each request.

Additional Capabilities The gateway can also support A/B testing, though the author suggests implementing the split‑engine in the open‑service to avoid overloading the gateway.

Technical Stack Recommendation • Language: Java + Groovy (Groovy allows dynamic addition of filters without restarting). • Microservice framework: Spring Boot. • Gateway component: Netflix Zuul. • Service registry: Consul. • Authentication: JWT. • Monitoring: Prometheus + Grafana. • Logging: Logback + ELK. • Load testing: JMeter.

Note The latter part of the original source contains promotional material for a ChatGPT community and related offers, which is not part of the technical discussion.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Javaapi-gatewaySpring BootroutingFilters
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

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.