LA RubyConf 2013

Summarized using AI

Where is my Scalable API?

Juan Pablo Genovese • February 23, 2013 • Burbank, CA

In this presentation at LA RubyConf 2013, Juan Pablo Genovese discusses the development of scalable APIs, particularly focusing on a transition from a resource-heavy Ruby on Rails API to a more efficient Goliath-based solution. He emphasizes the importance of scalability in the context of increasing user demand and the associated infrastructure costs. The following key points are highlighted:

  • Introduction to APIs: APIs are essential for integrating software, allowing developers to expose applications to the world and create collaborative services.
  • Case Study: Genovese presents an example involving a mobile game where user-uploaded videos led to rapid growth in requests, leading to inflated server costs under its existing Rails implementation.
  • Challenges Encountered: The project faced high operational costs due to an increasing number of user requests and a tight budget as a self-funded startup.
  • Solution with Goliath: The introduction of Goliath, a non-blocking I/O server, allowed for better efficiency in handling higher volumes of requests without the need for major language changes. It dramatically improved performance from 450 requests per second to over 1,300.
  • Technological Stack: The use of Beanstalk job queues for efficient task management and Couchbase database for data storage was also discussed, enabling seamless scalability.
  • Refactoring and Integration: The Rails API code was refactored to improve performance further, utilizing a more streamlined code base and enhancing integration with Goliath using Active Record.
  • Performance Testing: Through testing, it was verified that Goliath could handle heavy loads, and processing jobs per second improved from 40 to 200-250, ensuring a cost-effective scaling solution.
  • Final Thoughts: Genovese concludes that Goliath’s community support and the correct technology stack are vital for achieving the desired scalability without incurring prohibitive costs. He also highlights the benefits of stateless token management for enhanced performance.

Overall, this presentation offers insights into optimizing API performance and managing costs efficiently through the adoption of Goliath, making it relevant for developers facing similar scaling challenges.

Where is my Scalable API?
Juan Pablo Genovese • February 23, 2013 • Burbank, CA

You have a good ol' Rails application that provides an API. That app is gaining momentum and getting tons of new users every day. You need to double the servers to accommodate the infrastructure to the demand. Then, you get the bill from your cloud service provider and... THE HORROR!! Is big enough to make you cry. Well, here comes Goliath. A very tiny, well designed and FAST non-blocking IO server that will put a big smile in your face, since you're going to need much less money to serve the same (or more!) requests per second. A real case scenario, a social gaming application for mobile devices, will serve as guide to show you how good it is and how much progress can you make with just a little bit of work. From development tools and gems to deployment strategies, balancing and more, we'll show you how a resource consuming Rails API turns into a nimble and fast Goliath API. The real time Internet is calling, and Goliath will hurry to make you more real time than ever.

Help us caption & translate this video!

http://amara.org/v/FGdL/

LA RubyConf 2013

00:00:23.640 Hello, everyone. My name is Juan Pablo Genovese, and this is my first international conference. I've flown up from Argentina, and I work with Alturas Software. I'm excited to be presenting on scalable APIs today, and I appreciate the warm welcome from everyone here at LA RubyConf.
00:00:48.129 Thank you for having me. This place is incredible, surrounded by cars that I will never sell in my life. I just want to jump into one of these cars right now! The energy here is amazing. Last Thursday, I gave a workshop with the RailsBridge team, which I absolutely loved. Today’s talk is the culmination of all the work I’ve been doing these past few days.
00:01:22.960 Allow me to introduce myself briefly. I have been working in the software development industry for 16 years. I started when I was 17, didn't finish high school, and was already working. Initially, I did some Visual FoxPro and then transitioned to Visual Basic. Afterward, I worked with big banks in Argentina, processing hundreds of thousands of transactions per minute. I progressed from mainframe programming in COBOL and RPG on AS/400, and now I primarily work with Ruby.
00:02:14.969 I fell in love with Ruby in 2006, pretty much by accident, when I got my first project during the year Rails exploded. I started working with Ruby on Rails at Alturas Software, which is a fantastic company. They encouraged me to give this presentation, so here we are! You can follow me on Twitter @JuanPabloGenovese. My passions include walking, dancing the tango, and playing blues guitar.
00:02:54.360 Now, let's get into the subject of today's talk—scalable APIs. I believe everyone is somewhat familiar with what an API is, right? An API can be seen as a set of instructions or standards that allow you to use libraries or services. In today's context, it means you can expose your application to the world. A perfect example of this is Twitter, which has a widely used API where pretty much everyone signs up using it.
00:03:37.629 The first thing to understand about an API is that it allows for integration. Integration, in the current technological landscape, means that other people can use your software in the ways that you allow. This means you can gain more customers by allowing them to create software that interacts with your application, providing additional functionality that you may not develop yourself. In simpler terms, APIs offer a real-world case for collaboration between various services.
00:04:57.320 An example I can share comes from a mobile game for iOS and Android where users needed to upload videos. The team developed APIs in Ruby on Rails, and they were functioning fine as a JSON API connecting to mobile devices. This setup utilized Amazon Web Services S3, employing standard techniques, including a pool of HTTP proxies that channeled requests through several instances of AWS, each running its own Rails application.
00:06:00.580 However, the project faced some challenges. The client had a tight budget as it was a self-funded startup with no investors. The expenses began to soar as the user requests kept increasing. He was spending more and more on servers, and the need for cost-cutting while simultaneously enhancing performance became apparent. The project also required an easy scaling solution, maintaining all existing Ruby on Rails functionality while optimizing for these additional performance demands.
00:07:31.450 For inspiration, we looked at the success story of the application Draw Something, which attracted enormous traffic almost overnight after gaining popularity among celebrities. This application experienced significant challenges due to the overwhelming number of requests, needing to refactor code, add servers, and optimize overall performance. We learned from their experience to ensure we wouldn’t face the same pitfalls with our project.
00:08:21.410 This led us to Goliath, which is a non-blocking I/O server and web framework that works exceptionally well for scalable APIs. It operates similarly to JavaScript frameworks, but you don't have to switch languages to achieve a non-blocking server in Ruby. Goliath is built to efficiently handle high volumes of requests without sacrificing performance.
00:09:11.060 We employed Beanstalk, a fast and efficient job queue with a low memory footprint, making it perfect for our needs. Beanstalk allows for the scalability we required, as we could adjust the number of servers seamlessly. We also continued using Couchbase, a key-value database known for its speed and scalability, to manage our data.
00:09:54.880 One fantastic feature of Couchbase is its load distribution across multiple servers, minimizing single points of failure. The combination of Goliath and Couchbase proved to be a powerful duo, enabling us to quickly scale and adapt to growing demands while keeping tight control over our budget.
00:11:27.270 Additionally, we needed to refactor the Rails API code significantly because the original application was built by developers unfamiliar with Ruby. By concentrating on streamlining the code, we managed to process requests more efficiently. We created Ruby objects to handle work while maintaining the controller as a lightweight component responsible primarily for routing.
00:12:10.640 By employing Active Record, we enhanced the integration with Goliath, enabling seamless requests to our models. As a result, our application's performance vastly improved, going from 450 requests per second to over 1,300. We consolidated our server infrastructure, reducing from four Amazon EC2 instances to just one without compromising capacity.
00:12:54.260 Through thorough testing, we confirmed that Goliath maintained exceptional performance under heavy loads, further solidified by stress-testing with tools like JMeter. The video blog processing load also significantly improved, with processing capacities skyrocketing from 40 jobs per second to an impressive 200-250 jobs per second.
00:14:06.380 The ability for Goliath to manage notifications using both the Apple and Android notification systems provided us with a consistent and efficient means of communication with users. This bumped us in terms of processing efficiency while also providing substantial cost savings. We saved both time and money, allowing us to allocate resources effectively.
00:15:01.460 In conclusion, implementing Goliath into our system significantly positively impacted performance. Any critical API endpoints can easily be migrated to Goliath while allowing Rails to handle individual user requests with ease. You may find Goliath benefits really useful in various applications, especially for those needing to handle high traffic without breaking your budget.
00:15:55.790 The community surrounding Goliath is welcoming and helpful, with plenty of resources. Anytime I posted questions, I received responses from contributors quickly. I encourage you to investigate Goliath and its various drivers. Using the correct drivers is essential for avoiding issues like unnecessary blocking operations that could undermine Goliath's advantages.
00:16:58.880 We used token-based management for security instead of traditional session handling, ensuring a stateless experience that bolsters performance and scalability. The flexibility of Goliath makes it ideal for similar implementations, emphasizing the importance of choosing the right technologies to support your project’s needs.
00:18:06.600 Thank you all for your attention. It has been a real pleasure to be here today. If you have any questions or comments, I'm happy to discuss. Just let me know!
Explore all talks recorded at LA RubyConf 2013
+6