Spring Cloud Spring Cloud Gateway & Load Balancing 2 — Questions and Answers
Question 1: Which Spring Cloud component replaces Netflix Ribbon for client-side load balancing?
- Spring Cloud Balancer
- Spring Cloud LoadBalancer (Correct answer)
- Spring Cloud Proxy
- Spring Cloud Router
Correct answer: Spring Cloud LoadBalancer
Spring Cloud LoadBalancer is the Spring-native replacement for the deprecated Netflix Ribbon, providing pluggable client-side load balancing strategies.
Question 2: What is the default load balancing algorithm used by Spring Cloud LoadBalancer?
- Least connections
- Weighted round-robin
- Round-robin (Correct answer)
- Random selection
Correct answer: Round-robin
Spring Cloud LoadBalancer uses round-robin as its default algorithm, cycling through available service instances in order.
Question 3: Which Spring Cloud circuit breaker implementation is based on Resilience4j?
- Spring Cloud Hystrix
- Spring Cloud CircuitBreaker with Resilience4j (Correct answer)
- Spring Cloud Fault Tolerance
- Spring Cloud Retry
Correct answer: Spring Cloud CircuitBreaker with Resilience4j
Spring Cloud CircuitBreaker provides an abstraction with a Resilience4j implementation, replacing the deprecated Netflix Hystrix circuit breaker.
Question 4: What are the three states of a Resilience4j circuit breaker?
- Open, Closed, Half-Open (Correct answer)
- Active, Inactive, Standby
- Connected, Disconnected, Reconnecting
- Running, Stopped, Paused
Correct answer: Open, Closed, Half-Open
A Resilience4j circuit breaker transitions between Closed (normal operation), Open (blocking calls), and Half-Open (testing recovery) states.
Question 5: In Spring Cloud Gateway, which built-in filter adds a request rate limiting capability to protect downstream services?
- ThrottleGatewayFilter
- RequestRateLimiter GatewayFilter (Correct answer)
- RateLimit GatewayFilter
- QuotaFilter
Correct answer: RequestRateLimiter GatewayFilter
The RequestRateLimiter GatewayFilter factory in Spring Cloud Gateway uses a backend (e.g., Redis) to enforce rate limits on incoming requests per key.
Question 6: What Spring Cloud Gateway filter strips a path prefix before forwarding the request to the downstream service?
- RemovePrefix GatewayFilter
- StripPrefix GatewayFilter (Correct answer)
- PathRewrite GatewayFilter
- TrimPath GatewayFilter
Correct answer: StripPrefix GatewayFilter
The StripPrefix GatewayFilter removes a configurable number of path segments from the beginning of the request URL before routing to the downstream service.
Which Spring Cloud component replaces Netflix Ribbon for client-side load balancing?