HTTP vs gRPC

HTTP 503 Service Unavailable vs gRPC 14 UNAVAILABLE

HTTP 503 and gRPC UNAVAILABLE both signal a temporarily unavailable service that should recover. Both are the primary codes that tell clients to retry with backoff. They indicate the failure is transient, not a permanent bug.

Mô tả

The server is temporarily unable to handle the request due to maintenance or overload. Should include a Retry-After header.

Khi bạn thấy nó

During maintenance windows, server overload, or when the application pool is exhausted.

Cách khắc phục

Wait and retry. Check the Retry-After header. Scale up servers if it's a capacity issue.

Mô tả

The service is currently unavailable. This is most likely a transient condition, which can be corrected by retrying with a backoff.

Khi bạn thấy nó

The server is overloaded, shutting down, or a network partition occurred. This is the most common code to retry on, as it's explicitly transient.

Cách khắc phục

Retry with exponential backoff. If persistent, check the server health, load balancer configuration, and network connectivity between client and server.

Sự khác biệt chính

1.

HTTP 503 should include a Retry-After header; gRPC UNAVAILABLE relies on client-side retry policies.

2.

gRPC clients typically have built-in retry logic for UNAVAILABLE; HTTP clients must implement retry manually.

3.

HTTP 503 can be intercepted by CDNs to serve stale cached content; gRPC has no equivalent caching layer.

4.

Both indicate the client should retry — unlike 500/INTERNAL which may indicate a permanent bug.

5.

Load balancers use both codes to trigger failover to healthy backend instances.

Khi nào dùng cái nào

Return HTTP 503 during planned maintenance, capacity overload, or when a critical dependency is temporarily down. Return gRPC UNAVAILABLE for the same transient conditions in RPC services. Always signal that the condition is temporary and retrying is appropriate — use INTERNAL/500 if the error is unexpected and may not resolve on its own.

Tìm hiểu thêm