# DEADLINE_EXCEEDED: grpc: deadline exceeded after 5000ms while waiting for server to respond

- **ID:** `grpc/grpc-deadline-exceeded-server-busy`
- **Domain:** grpc
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

The server took longer than the client's deadline to respond, often due to server overload or slow processing.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| gRPC v1.44.0 | active | — | — |
| gRPC v1.51.0 | active | — | — |
| gRPC v1.59.0 | active | — | — |

## Workarounds

1. **Profile the server to identify slow operations (e.g., database queries, external API calls). Use tools like pprof or tracing. Example in Go: go tool pprof http://localhost:6060/debug/pprof/profile** (85% success)
   ```
   Profile the server to identify slow operations (e.g., database queries, external API calls). Use tools like pprof or tracing. Example in Go: go tool pprof http://localhost:6060/debug/pprof/profile
   ```
2. **Implement server-side rate limiting or request queuing to handle load spikes. Use a circuit breaker pattern to reject requests when the server is overloaded.** (75% success)
   ```
   Implement server-side rate limiting or request queuing to handle load spikes. Use a circuit breaker pattern to reject requests when the server is overloaded.
   ```
3. **Increase the client deadline to a reasonable value (e.g., 10 seconds) and add retry with exponential backoff. Example in Python with grpc.aio: await asyncio.wait_for(stub.MyRpc(request), timeout=10)** (80% success)
   ```
   Increase the client deadline to a reasonable value (e.g., 10 seconds) and add retry with exponential backoff. Example in Python with grpc.aio: await asyncio.wait_for(stub.MyRpc(request), timeout=10)
   ```

## Dead Ends

- **** — This masks the problem but doesn't fix server performance; long deadlines can cause resource leaks. (60% fail)
- **** — The underlying performance issue (e.g., slow database queries) will reappear after restart. (75% fail)
- **** — Repeated retries can overwhelm the server further, worsening the problem. (80% fail)
