Careeroza
Real World Example
Netflix and ShopEase Sale Day
Eureka was built at Netflix to track thousands of service instances on AWS, where machines come and go all day. Indian companies running Spring Cloud on VMs (banks, insurance and logistics platforms) use the same setup. For ShopEase, product-service scales from 2 to 6 instances on a Big Billion-style sale day without any caller config change:
09:55 product-service x2 --> Eureka [p1, p2] 10:00 sale starts, autoscaler starts p3..p6 10:01 p3..p6 register --> Eureka [p1..p6] 10:01 order-service refreshes its cache (every 30s) and spreads load over 6 14:00 traffic drops, p3..p6 shut down cleanly -> deregistered at once
The Order Service Calling Products by Name
@Service
@RequiredArgsConstructor
public class OrderService {
private final ProductClient productClient; // built from the @LoadBalanced builder
public OrderResponse placeOrder(PlaceOrderRequest req) {
ProductDto product = productClient.getProduct(req.productId());
if (product.stock() < req.quantity()) {
throw new OutOfStockException(product.id());
}
// save the order, reserve stock, call payment-service ... (later modules)
return new OrderResponse(1001L, "CREATED", product.price().multiply(BigDecimal.valueOf(req.quantity())));
}
}Example
curl -X POST localhost:8082/api/orders -H "Content-Type: application/json" \
-d '{"userId": 42, "productId": 7, "quantity": 2}'Example output
HTTP/1.1 201 Created
{"orderId":1001,"status":"CREATED","total":2998.00}
# order-service log
DEBUG o.s.c.l.core.RoundRobinLoadBalancer : product-service -> 10.0.0.13:8081