Skip to main content
PreparationZone Logo
PrepZone

Discovery, Config, Gateway

Service discovery, centralised config and API gateway with Spring Cloud.

Pass checkpoint below

Why this matters

  • Hardcoding http://inventory-service:8081 in every client breaks when services move, scale, or get replaced during a deploy.
  • A central config server lets you change payment gateway URLs or feature flags across all services without rebuilding images.
  • An API gateway gives BookStore customers one entry point while routing to catalog, order, and payment services behind the scenes.

Service discovery

L1 · Fresher

Clients resolve catalog-service instances via Eureka or Kubernetes DNS instead of hard-coded hosts.

Config server

L2 · Intermediate

Centralized configuration with refresh scopes — secrets still belong in vaults, not git repos.

API gateway

L3 · Advanced

Spring Cloud Gateway routes, rate-limits, and authenticates at the edge before BookStore microservices.

Distributed monolith smell

L4 · Expert

If every change requires coordinated releases, fix modulith boundaries before adding more network hops.

API Gateway
Catalog
Orders
Payments

Config server + service registry sit beside the mesh

Clients hit the gateway; services register with discovery and pull config.

Spring Cloud components for BookStore

  • Spring Cloud Gateway — reactive edge proxy; routes, rate-limits, and authenticates incoming traffic.
  • Eureka / Consul — service registry; instances register on startup and deregister on shutdown.
  • Spring Cloud Config — centralised application.yml served per service and profile.
  • @LoadBalanced RestClient — resolves service names through the registry instead of hardcoded hosts.
  • Spring Cloud Kubernetes — alternative to Eureka when you deploy on K8s and use native service discovery.

Service registry with Eureka

Java
{/* Eureka server (separate deployable) */}
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 3 sections

  • API Gateway routing
  • Centralised configuration
  • Load-balanced client calls

Test yourself

Answer these before moving on — recall is what makes it stick.