Search⌘ K
AI Features

Web Workers, Memory, and Network Calls

Explore how Rails handles web workers and network calls using Puma server and background jobs. Understand how deferring work to jobs improves resource use and manages slow or failing third-party API calls. Learn strategies to handle retries and reduce blocking in Rails applications.

In development, our Rails app uses the PumaPuma is a German multinational corporation that designs and manufactures athletic and casual footwear, apparel, and accessories. web server. This server receives requests and dispatches them to our Rails app (this is likely how it works in production as well). When a request comes in, Puma allocates a worker to handle that request. That worker works on only that request until a response is rendered—it can’t manage more than one request at a time.

When the response is rendered, the worker can work on another request. Puma keeps these workers in a pool, and that pool has a finite limit. This is because each worker consumes memory and CPU (even if it’s not doing anything), and because ...

...

It depends. In some configurations, the new request will be denied and the browser will receive an HTTP 503 (resource ...