Prompt
I’m troubleshooting a slow request in microservices and need to find the bottleneck
Latest observation
To find the bottleneck in a slow microservices request, trace the request end-to-end and compare where time is spent across services. Here’s a practical approach:
1) Start with one slow request
Pick a single slow request and capture:
- Trace ID / correlation ID
- Timestamp
- User-facing latency
- Endpoint / operation name
If you have distributed tracing (OpenTelemetry, Jaeger, Zipkin, Datadog, New Relic), this is the fastest path.
2) Break down the latency
Look for time spent in:
- API gateway / load balancer
- Service A
- Downstream service calls
- Database queries
- Cache misses
- External APIs
- Queue / async processing
- Serialization / deserialization
- Retries / timeouts
The slowest span is often the bottleneck, but also check for:
- Many sequential calls
- Fan-out to multiple services
- Hidden retries
- Long tail latency from one dependency
3) Check tracing spans
In the trace, identify:
- Largest span duration
- Gaps with no spans (could be app code not instrumented)
- Repeated spans to the same dependency
- Blocking calls or synchronous chains
Questions to ask:
- Is the service waiting on a DB query?
- Is it calling another service multiple times?
- Is there a retry loop?
- Is one downstream dependency consistently slow?
4) Correlate with metrics
For each service involved, compare:
- Latency p50/p95/p99
- Throughput
- Error rate
- CPU / memory / GC
- Thread pool saturation
- Connection pool usage
- Queue depth
- DB slow query logs
A bottleneck often shows up as:
- High CPU = compute-bound
- High DB latency / slow queries = database-bound
- Thread pool exhaustion = concurrency bottleneck
- Connection pool saturation = dependency bottleneck
- High retries/timeouts = upstream/downstream instability
5) Inspect logs around the request
Search by trace ID and look for:
- Long-running operations
- Timeout messages
- Retries
- Circuit breaker trips
- Rate limiting
- Lock contention
- Garbage collection pauses
6) Compare fast vs slow requests
Take:
- One fast request
- One slow request
Diff the traces:
- Same path but slower dependency?
- Different code path?
- Cache hit vs cache miss?
- Extra authorization or enrichment step?
- More items processed in the slow case?
7) Common bottlenecks in microservices
Typical culprits:
- Database query slowness
- Chatty service-to-service calls
- N+1 queries
- Retry storms
- Thread pool or async executor saturation
- Cold starts / container scaling
- GC pauses
- Network latency / DNS / service discovery
- Lock contention
- Large payload serialization
- Synchronous fan-out
8) If you don’t have tracing
Use a temporary manual method:
- Add timestamps before/after each major step
- Log duration for each downstream call
- Include request ID in every log line
- Measure:
- total request time
- each service call
- each DB query
- each external API call
9) A simple diagnostic workflow
- Find the slow trace.
- Identify the longest span.
- Check the dependency behind that span.
- Look at service and DB metrics.
- Compare with a fast trace.
- Confirm with logs or profiling.
- Fix the dominant bottleneck.
10) If you want, I can help you narrow it down
If you share any of the following, I can help interpret it:
- A trace screenshot or span timings
- Service call chain
- Metrics for p95 latency, CPU, DB time, retries
- Logs from the slow request
- Architecture details
If you’d like, I can also give you a step-by-step checklist for Jaeger/OpenTelemetry or help you analyze a sample trace.