Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
By, Dan Kozlowski & Colin Kelley We had a real-time API in Rails that needed much lower latency and massive throughput. We wanted to preserve our investment in business logic inside ActiveRecord models while scaling up to 1000X throughput and cutting latency in half. Conventional wisdom would say this was impossible in Ruby, but we succeeded and actually surpassed our expectations. We'll discuss how we did it, using Event-Machine for the reactor pattern, Synchrony to avoid callback hell and to make testing easy, Goliath as the non-blocking web server, and sharding across many cooperative processes.
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 presentation titled "High Performance APIs in Ruby using ActiveRecord and Goliath" by Dan Kozlowski and Colin Kelley at RailsConf 2015, the speakers delve into the challenges and solutions they encountered while scaling their ROL API for high throughput and low latency. The ROL API was originally built on a Rails stack which struggled to meet the demands of a new client requiring significantly higher performance. The initial setup could only handle five requests per second per connection, while the client needed at least thirty requests per second per connection, translating to an 8,000-fold increase in throughput. The following points were discussed: - **Performance Challenges:** The Global Interpreter Lock (GIL) in MRI Ruby limited parallel execution. To overcome this, the team utilized multiple cooperative Ruby processes for sharding across CPU cores. - **Reactor Pattern:** They implemented the reactor pattern to manage high levels of concurrency without threading complexities, with EventMachine serving as the core library to manage asynchronous I/O operations. - **Use of Synchrony:** The Synchrony gem enabled a linear coding style while handling asynchronous actions, simplifying the control flow and enhancing readability. - **Goliath Web Server:** A high-performance web server, Goliath, built upon EventMachine and Synchrony, was crucial for handling incoming requests as separate fibers rather than threads, thus improving performance by avoiding heavy locking mechanisms. - **Software Design Decisions:** Key design patterns included reducing dependencies in Active Record models, encapsulating exception handling with the Exceptional Synchrony gem, and utilizing immutable value classes to avoid internal state changes. - **Load Testing Results:** Rigorous load tests revealed that their new system could achieve a median response time of 93 milliseconds for 400 requests per second and eventually peaked at 2,000 requests per second, significantly exceeding the original SLAs. - **Innovative API Sharding:** Implementing sharding across multiple processes improved response times and balanced loads effectively, with fallbacks to overflow numbers during heavy loads. In conclusion, the transformation of their ROL API not only demonstrated the viability of building high-performance applications in Ruby but also highlighted the effective utilization of modern libraries and architectural patterns. The overall success drastically enhanced their service capacity, indicating strong potential for Ruby in high-traffic scenarios. The speakers encouraged the exploration of Goliath as a solution for next-generation mixed API servers.
Suggest modifications
Cancel