Elevator Pitch
Oh no! Computers are not doubling in speed every two years anymore! How can we make software run faster? You and your Rails app cannot just wait doing nothing, so join me to explore how we can leverage concurrency and parallelism concepts to enhance performance and scalability!
Description
Overview
With hardware advancements plateauing, the landscape of computing has shifted its focus towards optimizing software (not hardware) for better performance. The constraints of single-threaded processes are evident, urging us to explore concurrency and asynchronous techniques. This talk delves into the realm of Ruby (and Rails), exploring how we can leverage concurrency and parallelism concepts to enhance performance and scalability.
Objectives
- Understanding the Need for Concurrency:
- Explore the transition from single-threaded to multi-threaded processing.
- Discuss the significance of parallelism in the context of modern computing.
- Exploring Ruby’s Concurrency Story:
- Examine Ruby’s historical design constraints, particularly its handling of threads and the Global Interpreter Lock (GIL).
- Explore the differences between the concurrency/parallelism models of Ruby: threads, Ractors, and fibers.
- Concurrency in Rails:
- Introduce and elucidate the concept of concurrency within the Rails framework.
- Showcase techniques like async queries, Falcon (an async web server), and managing async HTTP requests to improve Rails application performance.
- Understanding Common Pitfalls and Issues:
- Discuss the edge cases and pitfalls of asynchronous operations and how to avoid them.
- There’s no silver bullet. It’s important to understand the trade-offs of concurrency and parallelism and when to use them.
Session Structure
- Introduction to Concurrency and Parallelism:
- Defining concurrency and parallelism in modern computing.
- Differentiating between cooperative and preemptive models.
- Understanding Threads, Ractors, and Fibers:
- Delving into the nuances of threads, Ractors, and fibers.
- Contrasting their cooperative and preemptive nature for effective utilization in Ruby applications.
- Leveraging Concurrency in Rails:
- Demonstrating the utilization of async queries in Rails.
- Exploring Falcon as an async web server and managing asynchronous HTTP requests within Rails.
- Discussing other techniques for improving (visible) performance:
- Action Cable
- Lazy-loaded images
- Lazy-loaded Turbo Frames
- Async tests
- Concurrently adding indexes with Postgres
- Caveats and Pitfalls:
- Discussing the edge cases and pitfalls of asynchronous operations.
- Race conditions
- Deadlocks
- Balancing Database max connections
- Highlighting the importance of benchmarking and testing.
- Let’s ensure we’re optimizing the right thing.
- Fix the bottleneck, not the symptom.
Key Takeaways
- Insight into the limitations and potential of Ruby’s concurrency model.
- Strategies for integrating concurrency into Rails applications for improved performance.
- Understanding the edge cases and pitfalls of asynchronous operations.
Target Audience