Menu

Threading and Code Execution in Rails: Executor, Reloader, and Load Interlock
📰

Threading and Code Execution in Rails: Executor, Reloader, and Load Interlock

DEV Community: ruby·Shrouk Abozeid·about 2 hours ago
#DUgXkx4J
#devtoruby#devto#dev#application#rails
Reading 0:00
15s threshold

Rails handles concurrency for us in many situations. But what happens when we create our own threads? How does Rails safely reload application code while other threads are running? And what does the Executor have to do with database connections and autoloading?

I recently explored these questions while reading the Rails 8 guides. Here are my notes, with examples to make the concepts easier to understand.

1. How Rails Handles Concurrency

Rails allows different operations to run concurrently.

For example, when using a threaded web server such as Puma, multiple HTTP requests can be processed simultaneously. Active Job can also execute multiple jobs concurrently, depending on the queue adapter and its configuration.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.