A 311 service backend calls Claude over REST and must keep request threads responsive. Which practice fits?
Select an answer to reveal the explanation.
Short Explanation
311 shouldn't freeze the whole lobby while Claude thinks. Async HTTP clients keep worker threads free to serve other residents.
Full Explanation
Three-one-one service backends that call Claude over REST and must keep request threads responsive should use async HTTP clients for those Claude calls so worker threads are not blocked. Asynchronous I/O fits because Claude latency is network-bound and often multi-second: holding a thread hostage for each in-flight generation collapses concurrency under peak 311 load and delays unrelated resident requests. Async clients free the event loop or thread pool to serve other work while awaiting Claude responses. Increasing the request thread pool size to cover blocking Claude call latency fails by concept: it merely adds more threads that sit idle waiting on the network, wastes memory and context-switching overhead under peak 311 load, and still leaves every in-flight Claude call occupying a thread instead of freeing it. Using synchronous HTTP clients with connection pooling for Claude calls fails by concept: connection pooling reuses sockets but does not make the call non-blocking, so each request still hogs a worker thread for the full duration of the Claude response and starves the pool under concurrent resident traffic. Dispatching calls to a separate background worker pool fails by concept: moving the blocking call to another pool of threads still blocks threads one-for-one with in-flight requests instead of using non-blocking I/O. Exam caveat: async does not remove the need for timeouts, cancellation, and backpressure—abandoned resident sessions should cancel outstanding Claude calls where possible—and idempotent request design still matters for retries. Operational check: load-test the 311 Claude path with concurrent synthetic tickets using an async HTTP client, compare thread/event-loop utilization against a synchronous baseline, and verify timeouts return controlled errors instead of wedging workers.