Running a Background Job

All of our failure mitigation so far has one limiting factor: the time needed to respond to a web request. As the application currently stands, we’re making our Stripe API call inside our user’s HTTP request, which is slow. If the Stripe API gave us a temporary error, our best response would be to retry the request in a few moments, but we can’t necessarily do that in the space of a typical web request.

Moving our payment processing to a background job, however, allows us to get some response back to the user more quickly, as well as gives us more leeway for robust error handling. Using a background job also makes it easier to integrate other tasks, such as sending a receipt back to the user or integrating with reporting ...

Get Take My Money now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.