Member-only story

Become a Rails Background Job Pro: Replicating Active Jobs with Pure Ruby

Gokul
5 min readMay 13, 2023

--

What?

Background jobs are processes that operate in the background of a web application, independent of the primary user interface and request/response cycle. It permits you to execute lengthy or resource-intensive duties asynchronously, without obstructing the main thread or affecting the user experience.

In a typical web application, the user sends a request to the server, and the server processes the request and returns a response. This process usually takes a few milliseconds to a few seconds, depending on the complexity of the request and the load on the server.

Some requests, such as generating PDF reports, sending email notifications, or processing lots of data, may require additional time and resources. If these duties are conducted synchronously, the server may become unresponsive or time out, degrading the user experience. Background jobs enable you to delegate these tasks to a separate process that operates in the background, independent of the request/response cycle, to avoid these issues. Consequently, the user can continue to interact with the application while the task is executing, and the server can manage more requests concurrently.

Typically, a job queue system manages background tasks by controlling the execution order…

--

--

Gokul
Gokul

Responses (1)