I've been working more with concurrency in Ruby recently, and I keep seeing various articles using "threads" and "process" interchangeably.

What are the actual definitions of these terms? Is a process composed of multiple threads?

Let's say I use Unicorn/Puma/etc.. as a web server.

Am I correctly understanding the following?

  1. Each Unicorn (or whatever) worker is its own process. It has an individual listing in the Linux process list (ps aux).

  2. Each worker has multiple threads. These threads share memory and other context because it's all really one process, but simulate the process doing multiple things at once.

  3. Each thread has (at most) one connection to a Database which it uses to query or write data. It checks this connection out from a Connection Pool, which is a collection of connections available for use

  4. Each connection pool applies to one process. So if my background job processor (e.g. Resque, Delayed Job, etc...) has a concurrency of "25" it means that each worker process gets up to 25 connections to distribute among its threads.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.