Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
In this talk we'll learn about the options we have to let a computer running Ruby do multiple things simultaneously. We'll answer questions such as: What's the difference between how Puma and Unicorn handle serving multiple Rails HTTP requests at the same time? Why does ActionCable use Eventmachine? How do these underlying mechanism actually work if you strip away the complexity?
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the video titled **Introduction to Concurrency in Ruby**, Thijs Cadier explores various concurrency models in Ruby, providing insights into how to effectively implement simultaneous tasks within the language. Cadier introduces the concept of concurrency and offers a structured approach to understanding three primary methods: multiprocess, multithreading, and event-driven programming. Throughout the presentation, he illustrates these concepts using a simple chat server implementation, which he demonstrates through live coding. ### Key Points: - **Concurrency Models:** Cadier outlines three main concurrency models in Ruby: - **Multiprocess Model:** This model, used by servers like Unicorn, involves forking processes for handling tasks. Each child process operates independently, which simplifies concurrency management but increases system resource usage. - **Multithreading Model:** By creating multiple threads within a single process, this model allows shared memory access among threads. Cadier explains the benefits and complexities, such as needing mutexes to handle data consistency, potentially leading to deadlocks if not managed carefully. - **Event Loop Model:** This method efficiently handles many connections by processing one event at a time using constructs like fibers. Cadier emphasizes that while it appears to enable concurrency, it actually runs tasks sequentially but does so with minimal overhead. ### Examples & Demonstrations: - **Chat Server Implementation:** Cadier builds a chat server as a practical example across all three concurrency models. He discusses: - **Client-Side Execution:** Using basic networking features from Ruby's standard library, allowing user input to initiate connections and read messages. - **Server-Side Execution:** Implementing the server logic using the different concurrency models to showcase their operation in real-time. - Cadier performs live demonstrations of each implementation, emphasizing the structure of connections and process management. ### Takeaways: - Each concurrency model has its specific use cases, strengths, and weaknesses: - **Multiprocess model** is robust against failures, suitable for applications needing fault tolerance. - **Multithreading** provides a lower memory footprint but requires careful state management. - **Event-driven programming** excels at scalability, making it ideal for high-traffic applications, though it can lead to complex programming scenarios. In conclusion, the choice of concurrency model in Ruby depends largely on the requirements of the application, with each approach offering distinct advantages and operational challenges. Cadier invites the audience to explore these models further through hands-on experimentation with the provided code examples.
Suggest modifications
Cancel