3. Software Engineer @ CloudWalk
🎯 Focused on Ruby on Rails and Elixir
gustavoaraujo.dev
garaujodev
garaujodev
Gustavo Araujo
4. Software Engineer @ CloudWalk
🎯 Focused on Ruby on Rails and Elixir
💜 Passionate about code quality, observability, and performance
gustavoaraujo.dev
garaujodev
garaujodev
Gustavo Araujo
5. Software Engineer @ CloudWalk
🎯 Focused on Ruby on Rails and Elixir
💜 Passionate about code quality, observability, and performance
Sharing knowledge through talks and technical content
gustavoaraujo.dev
garaujodev
garaujodev
Gustavo Araujo
15. ⚙Concurrency Model ⚡ Performance ✅ Best Use Case ❌ Limitations
WebRick
Single-threaded +
single-process
Very low Development only
Not production-ready;
removed in Rails 6+
Ruby Webservers
16. ⚙Concurrency Model ⚡ Performance ✅ Best Use Case ❌ Limitations
WebRick
Single-threaded +
single-process
Very low Development only
Not production-ready;
removed in Rails 6+
Passenger
Multi-threaded +
multi-process (hybrid)
Medium to High
Easy-to-deploy
production apps
Advanced features require
paid license
Ruby Webservers
17. ⚙Concurrency Model ⚡ Performance ✅ Best Use Case ❌ Limitations
WebRick
Single-threaded +
single-process
Very low Development only
Not production-ready;
removed in Rails 6+
Passenger
Multi-threaded +
multi-process (hybrid)
Medium to High
Easy-to-deploy
production apps
Advanced features require
paid license
Unicorn
Multi-process
(no threads)
High for CPU-bound
apps
Apps requiring
process-level isolation
No concurrency per
worker; not ideal for
I/O-bound apps
Ruby Webservers
18. ⚙Concurrency Model ⚡ Performance ✅ Best Use Case ❌ Limitations
WebRick
Single-threaded +
single-process
Very low Development only
Not production-ready;
removed in Rails 6+
Passenger
Multi-threaded +
multi-process (hybrid)
Medium to High
Easy-to-deploy
production apps
Advanced features require
paid license
Unicorn
Multi-process
(no threads)
High for CPU-bound
apps
Apps requiring
process-level isolation
No concurrency per
worker; not ideal for
I/O-bound apps
Puma
Multi-threaded +
multi-process (clustered)
Highly configurable —
scales with threads
and workers
Modern Rails apps
needing concurrent I/O
handling
Requires tuning
(threads/workers + DB pool
alignment)
Ruby Webservers
19. Puma
✅ ❌
Clustered Mode Best for Multi-core CPUs, CPU-bound applications
Higher memory usage since each worker
is a separate process
20. Puma
✅ ❌
Clustered Mode Best for Multi-core CPUs, CPU-bound applications
Higher memory usage since each worker
is a separate process
Single Mode Best for I/O-bound apps, lower memory usage
Limitation: Single process, may not fully
utilize multi-core CPUs
21. How Many Workers?
Scenario Recommendation
🖥 App runs on VM/bare metal Use 1 worker per available CPU core
22. How Many Workers?
Scenario Recommendation
🖥 App runs on VM/bare metal Use 1 worker per available CPU core
📦 App runs in Docker/Kubernetes Respect container CPU limit (cpu_limit = 2) → set workers = 2
23. How Many Workers?
Scenario Recommendation
🖥 App runs on VM/bare metal Use 1 worker per available CPU core
📦 App runs in Docker/Kubernetes Respect container CPU limit (cpu_limit = 2) → set workers = 2
🧠 App has high memory usage Use fewer workers, increase threads
24. How Many Workers?
Scenario Recommendation
🖥 App runs on VM/bare metal Use 1 worker per available CPU core
📦 App runs in Docker/Kubernetes Respect container CPU limit (cpu_limit = 2) → set workers = 2
🧠 App has high memory usage Use fewer workers, increase threads
🧪 Unclear limits or mixed load Start with 2–4 workers and benchmark
25. How Many Threads?
Factor Guideline
🔄 I/O-bound app Use more threads (e.g. 16–32) to handle concurrency
26. How Many Threads?
Factor Guideline
🔄 I/O-bound app Use more threads (e.g. 16–32) to handle concurrency
🧮 CPU-bound app Fewer threads (e.g. 4–8) to avoid contention
27. How Many Threads?
Factor Guideline
🔄 I/O-bound app Use more threads (e.g. 16–32) to handle concurrency
🧮 CPU-bound app Fewer threads (e.g. 4–8) to avoid contention
🧵 Low traffic env (dev/staging) Use something like threads 1, 4
29. Platform as a Service (PaaS)
Example: Heroku, fly.io
✅ Easy to get started and Built-in autoscaling
30. Platform as a Service (PaaS)
Example: Heroku, fly.io
✅ Easy to get started and Built-in autoscaling
❌ Cost to scale and limited control over infrastructure for advanced tuning
31. Infrastructure as a Service (IaaS)
Example: AWS, GCP, Azure
✅ Full control (Instances, Auto Scaling, Load Balancers)
32. Infrastructure as a Service (IaaS)
Example: AWS, GCP, Azure
✅ Full control (Instances, Auto Scaling, Load Balancers)
❌ High availability requires manual setup, fixed resource provisioning
34. Container
Orchestration
Example: Kubernetes (can run on AWS, GCP, Azure, or On-Premise)
✅ Portability and fine-grained control over resources(CPU, memory, limits per pod)
❌ Steep learning curve — complex concepts (pods, services, volumes)
41. Common Pitfalls
🧩 Issue 🛠 Cause ⚠ Impact
DB Pool Mismatch THREADS > pool in database.yml Connection timeouts and ActiveRecord errors
42. Common Pitfalls
🧩 Issue 🛠 Cause ⚠ Impact
DB Pool Mismatch THREADS > pool in database.yml Connection timeouts and ActiveRecord errors
Excessive Thread Count Threads set too high without real concurrency need Increased memory usage, thread contention, and
degraded app performance
43. Common Pitfalls
🧩 Issue 🛠 Cause ⚠ Impact
DB Pool Mismatch THREADS > pool in database.yml Connection timeouts and ActiveRecord errors
Excessive Thread Count Threads set too high without real concurrency need Increased memory usage, thread contention, and
degraded app performance
Resource Overcommit Too many workers × threads for available CPU/memory Application instability due to memory exhaustion
(OOM) or CPU throttling