Handling Slow Third-Party APIs in Laravel with Timeouts, Retries and a Circuit Breaker
A developer describes how a slow shipping-rate provider exhausted PHP-FPM workers and took down unrelated pages in a Laravel app. The article explains that Laravel's HTTP client ships with a 30-second timeout, no retries, and no automatic failure on error status codes, which can tie up workers and treat errors as data. It recommends short explicit timeouts, retrying only transient failures like connection errors, 429 and 5xx responses, and using backoff with jitter that honours Retry-After headers. The author proposes a shared HTTP macro in AppServiceProvider so every partner call follows the same rules, and adds safe retries for writes via idempotency keys and a circuit breaker to fail fast when a partner is down.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in