Empower growth and innovation with the latest Program Dev insights

Why do APIs intermittently time out, restart helps temporarily, but logs show no errors?

Sep 8, 2026 Read: 19

APIs occasionally time out and recover temporarily after a restart, yet logs show no obvious errors. This usually points not to a business-logic bug, but to connection pools, thread pools, or underlying resources being exhausted without timely release. Restart forcibly clears those occupied resources, so it appears as 'restart fixes it.' Using 2026 troubleshooting habits, first separate intermittent timeouts from sustained high latency, then gather evidence in three directions: resource usage, downstream dependencies, and code changes.

  • Intermittent timeouts: Most requests are normal, but timeouts or obvious slowdowns occur in a certain time window, and restart temporarily relieves them. Prioritize checking connection pools, thread pools, GC pauses, and downstream jitter.
  • Persistent high latency: Every request is slow from the beginning, and restart makes no significant difference. Prioritize code performance, slow SQL in the database, and capacity of dependent services.

First Understand What a Restart Really Clears

A restart resets connection pools, thread pools, file handles, and local caches, and also interrupts queued task backlogs. So 'better after restart' does not mean repaired; it simply zeros out accumulated usage from a period of time. Typical occupancy includes one slow query holding a database connection, or an external API that never returns, dragging all worker threads down. Requests are usually interrupted by timeout while waiting for a connection or queue slot, before entering the business exception branch, so logs do not contain full stack traces. Thus, before handling the issue next time, first add pool metrics, thread counts, and GC samples from 5–10 minutes before restart, confirm which type of resource is saturated, and then decide whether to restart.

Prioritize Checking Whether Connection Pools and Thread Pools Are Saturated

One common root cause is pool saturation. When the connection pool is full, logs may show 'connection is not available'. When the thread pool is full, CPU is not high, but request queueing time continuously grows. The signature is: requests work fine when there are idle resources in the pool, but they time out once the pool is full. If the active count is not high and timeouts still occur, stop tuning pool parameters and turn to downstream dependencies or GC.

Experience ranges for reference: the connection pool upper limit is usually 2–3 times the business peak, assuming the database has enough headroom; internal dependency timeouts can be set from 300 ms to 3 s, and external services can be relaxed to around 5 s, but paired with circuit breaking and graceful degradation.

  • Connection pool: examine connection wait time and active count, and look for calls that occupy a connection for a long time without returning it.
  • Thread pool: examine queue depth and rejection count; check business pool and framework pool separately.
  • Slow SQL: align the timeout window with slow logs; if there is overlap, handle slow queries first.

In one admin console investigation, only restart records existed, with no pool metrics. We asked operations to add active sampling 5 minutes before restart in the next release window. Timeouts were still intermittent, but once data was obtained, we found that a report query scheduled on the hour was occupying the connection pool for about 20–40 minutes. Only after optimizing the query did the problem close out. In typical ranges, a connection wait over 500 ms or thread queueing above 30% deserves close attention.

Then Examine Downstream Dependencies and Retry Amplification

APIs also call external services, caches, and message queues. When downstream slows down intermittently and the caller's timeout is too long, threads can get stuck; when multiple upstream callers wait at the same time, your own thread pool can also be exhausted. First use tracing to look at the latency distribution and tell whether a single request is slow or every request is slow.

Use retries cautiously: when downstream is overloaded, automatic retry is a second shock wave. You need random backoff and an upper retry limit; non-idempotent APIs should not be retried automatically.

Also Check Resource Leaks and GC Pauses

If the latency curve rises gradually with uptime and drops after restart, consider memory or file-handle leaks first. Full GC can pause threads for tens to hundreds of milliseconds, and when superimposed with downstream timeouts it becomes an intermittent timeout. Check whether the heap rises in steps, Full GC is becoming more frequent, or file descriptors are near the limit. Fix the leak before adding memory; otherwise, you are merely postponing the risk.

Order of the Troubleshooting Evidence Chain

When no explicit error exists, gather evidence in the following order, and change only one variable at a time. Adjusting connection pool, GC, and timeout parameters together tends to mask the real cause.

  1. Confirm that connection pool, thread pool, GC, and downstream latency data exist for 5–10 minutes before the restart.
  2. Investigate in sequence: connection pool → thread pool → downstream → GC/leak.
  3. Use a timeline to align the timeout window with slow SQL, Full GC, and downstream errors.
  4. Once identified, make small changes; do not change multiple parameters at once.
  5. After the fix, observe for 1–2 weeks. Close the ticket only when P99 no longer has spikes.

If the problem appears right after a new release, add code change review to the first step; if logs already have a clear exception stack, locate it directly from the stack instead of mechanically following the entire process.

Applicable Boundaries and Cost Comparison

The approach in this article applies to backend services with intermittent timeouts that appear after running for a while, are alleviated by restart, and show no business stack trace in logs—especially Java, Go, and .NET services that use connection pools, thread pools, and GC. When a low-concurrency admin console experiences similar issues, first check database lock waits and network jitter; there is no need to turn every connection pool and thread pool parameter.

  • Applicable: error logs only contain timeout or connection notifications, and the first round of requests after restart works normally.
  • Not applicable: the service is slow from the moment it starts, restart does not help, or the exception stack points directly to business code.

There is a cost trade-off between two handling paths. Directly increasing the connection pool and timeouts takes about 0.5–1 day to change and 1 week to observe; it suits restoring business first, but the next peak may see recurrence. Adding monitoring first, waiting for a failure sample, and then diagnosing takes about 1–2 days of preparation, 2 hours to 2 days to locate and fix, and a recommended 2-week full observation. This is often 2–4 times more expensive, but it can end the cycle of repeated restarts. If production is already impacted, you can choose the former first, but afterwards you still need to follow the evidence chain to identify the root cause.

FAQ

Why do APIs intermittently time out even when logs show no obvious errors?

Requests are typically interrupted by timeout while waiting for a connection or a thread queue slot, before they enter business exception logic, so there is no notable stack trace. You need to find evidence in resource pool occupancy and call-chain timeline.

Can extending the timeout solve the problem?

Extending the timeout only makes the caller wait longer. If the pool is occupied, the queue just grows longer. Adjust timeouts together with resource pool metrics, and pair it with rate limiting or circuit breakers.

I forgot to capture evidence before restarting. Can I still locate the issue later?

Yes, but it is less efficient. First add before/after restart monitoring, and retain thread dumps, GC logs, and pool snapshots when it happens next time. Historical monitoring can also help narrow down possible time windows.

Why does an intermittent timeout remain even after the connection pool is doubled?

Increasing the pool size does not reduce the hold time of individual connections. If a slow SQL or a downstream call is stuck, even a larger pool can become full. You should shorten the hold time or make the holder release the resource sooner.

Have a similar project in mind?
Contact us for a one-to-one project reference proposal
Obtain Proposal
Are you ready?
Then reach out to us!
+86-13370032918
Discover more services, feel free to contact us anytime.
Please fill in your requirements
What services would you like us to provide for you?
Your Budget
ct.
Our WeChat
Professional technical solutions
Phone
+86-13370032918 (Manager Jin)
The phone is busy or unavailable; feel free to add me on WeChat.
E-mail
349077570@qq.com
Submitted successfully
Thank you for your trust. We will contact you soon!
Recommended projects for you