Ruby Execution Models and Threading
To Thread or Not to Thread: An In-Depth Look at Ruby’s Execution Models - Shopify

To Thread or Not to Thread: An In-Depth Look at Ruby’s Execution Models - Shopify

5/31/2022

What this post added

This post details the mechanics and reasoning behind the popularity of threaded Ruby servers, explaining the concepts of static and processing memory and how they contribute to overall memory usage. It introduces the Copy on Write (CoW) mechanism and its implications for memory sharing between forked processes. The post also highlights the importance of accurate memory metrics, explaining why RSS can be misleading and introducing Proportional Set Size (PSS) and detailed Linux smaps_rollup data. It provides practical advice for improving CoW efficiency, such as using `preload_app` and leveraging Rails' `eager_load_namespaces`. Finally, it presents the case for process-based servers, emphasizing their clean timeout mechanism for handling problematic requests.

Read the original post ↗