Building Serverless Applications in Ruby with AWS Lambda

Summarized using AI

Building Serverless Applications in Ruby with AWS Lambda

Alex Wood • April 18, 2019 • Fukuoka, Japan • Talk

In the video titled 'Building Serverless Applications in Ruby with AWS Lambda,' presented by Alex Wood at RubyKaigi 2019, attendees are introduced to the concept of building serverless applications using Ruby in conjunction with AWS Lambda. The session explores various tools and methodologies that facilitate the development of serverless applications while emphasizing the advantages of this compute model.

Key points discussed in the presentation include:

  • Introduction to AWS Lambda: Alex provides a foundational understanding of AWS Lambda, describing it as a managed service that abstracts server management, enabling developers to focus on writing code without worrying about underlying infrastructure.

  • Benefits of Serverless Computing: The video outlines the benefits of serverless, including automatic scaling, pay-per-use billing, built-in availability, fault tolerance, and a reduction in operational overhead. This model allows applications to handle traffic spikes efficiently and minimizes the risks of outages.

  • Common Misconceptions: Alex addresses misconceptions about serverless computing, explaining that while the hype may be overstated, the practical advantages make AWS Lambda a compelling choice for many use cases.

  • Open Source Tools for Ruby: The presentation highlights several open-source tools vital for Ruby development in serverless environments, such as the AWS SAM CLI for managing serverless applications, the AWS SDK for Ruby, and the AWS Record library for DynamoDB. These tools improve the development workflow, allowing for local testing and seamless dependency management.

  • Live Demonstration: A notable part of the session includes a live demo of a serverless application built with Sinatra, where users can upload and validate dog pictures using AWS Lambda functions. This example illustrates how efficiently serverless architecture can streamline application processes without needing extensive backend setup.

In conclusion, Alex emphasizes the holistic advantages of adopting serverless architectures, particularly how AWS Lambda empowers developers to construct robust applications with improved scalability, security, and reduced management overhead. He encourages the audience to experiment with serverless for their projects, reinforcing the potential of Ruby applications in this modern framework. The session wraps up with an invitation to further explore the evolving landscape of serverless technologies and the specific tools available for Ruby developers.

Building Serverless Applications in Ruby with AWS Lambda
Alex Wood • April 18, 2019 • Fukuoka, Japan • Talk

Come join us and learn about how you can build serverless applications using Ruby on AWS Lambda! We will demonstrate how to create Ruby serverless functions for web APIs as well as for event-driven applications, then build, test and deploy them to production. We'll also discuss general best practices for developing serverless applications.

RubyKaigi 2019 https://rubykaigi.org/2019/presentations/alexwwood.html#apr18

RubyKaigi 2019

00:00:00.380 All right, so welcome to the last session of the day. We're going to talk a little bit about building serverless applications in Ruby using AWS Lambda.
00:00:03.720 A little bit about myself: a fun fact about me is that I actually don't have the same job that I had when I submitted this talk. For almost six years, I was on the AWS SDK for Ruby team, and I'm now changing roles to work full-time at AWS Lambda, focusing on building out open-source tools for serverless applications.
00:00:13.469 I still love Ruby and have talked a lot about it. I'll still be working with you all, but my roles have changed a bit. Fortunately, they remain relevant to what we're discussing today. You can find me on Twitter at Alex W Wood, and I tend to gauge how well my talk is going by how much people are discussing it on Twitter.
00:00:29.480 So, if you're looking down at your screen, I’m just going to presume that you're talking all about what we're doing here, and I'm totally cool with that. Now, what we're going to cover today is a brief overview of what AWS Lambda is and the ecosystem surrounding it for building applications.
00:00:48.480 We'll talk about several open-source tools that we own within AWS, such as the SAM CLI, the AWS SDK for Ruby, and the AWS Record library for DynamoDB. Additionally, we'll do a demo of an application that's a hybrid of both web APIs and event-driven functions to showcase the power of what we can achieve with minimal code and configuration.
00:01:53.689 Now, let's dive into the topic of serverless. It's often said that serverless is dead. I’m sorry for those of you who came to a talk about serverless, but it turns out that the term 'serverless' can elicit very strong reactions from people. The hype surrounding serverless may not solve all your problems.
00:02:52.000 I believe AWS Lambda represents a new compute model. It differs from virtual machines and containers, allowing you to focus less on the hype and more on the actual tangible benefits it provides. So, what does serverless actually mean? A useful definition would be that it means no servers to provision or manage. You're no longer worried about how to set up or configure servers.
00:03:50.240 AWS Lambda is a managed service that handles much of this on your behalf. It scales automatically with usage, able to handle a thousand concurrent requests by default. You can raise that limit even higher if needed. Importantly, AWS Lambda scales down to zero when not in use, which is useful for infrequent applications or those with bursty usage.
00:04:02.920 You’re essentially paying for what you use. Many customers who have switched to AWS Lambda have seen significant savings, as paying only for compute capacity that is actually used increases efficiency. Additionally, it has built-in availability and fault tolerance. When it comes to scaling, it handles quick spikes in traffic far more effectively than traditional methods, allowing for immediate response without delays.
00:04:50.000 In the event of an instance failure, AWS Lambda seamlessly provides a new container to handle requests, relieving you from worrying about outages. Developing production applications is complicated and requires careful consideration of many factors.
00:05:03.000 We need to think beyond just the code, focusing on coding tests, availability, fault tolerance, load balancing, and scalability. What are the different types of auto-scaling solutions that are available? We must also consider routine tasks such as patching the operating system.
00:06:09.670 AWS Lambda eliminates the need for us to deal with these tedious tasks. It automatically manages load balancing, distributes requests across containers, scales as needed, and helps with server and container failures, significantly reducing the operational overhead.
00:07:05.000 Security is another area where AWS Lambda provides benefits. It offers reduced surface area for security threats and automates much of the operational management, including patching and updates. When we discuss user authentication and monitoring, AWS Lambda is well-integrated with other AWS managed services, requiring less configuration than what may have been needed in previous iterations.
00:08:01.960 This efficacy has made AWS Lambda suitable for a variety of use cases, including backend services, live data processing through services like Kinesis for real-time streaming data, and policy engines for infrastructure management, ensuring security and compliance.
00:08:59.000 Now, shifting gears, this is RubyKaigi. We want to talk about open source and tools specific to Ruby. We'll cover several tools that we maintain as well as interesting community tools. On day three, you'll have a chance to hear about Ruby on Jets, as well as the Serverless framework and various tools aimed at integrating Ruby on Rails into Lambda environments.
00:09:42.300 One notable tool is the AWS SAM CLI, which facilitates the management of serverless applications. It aids in generating new projects, building them in an idiomatic way for serverless use, and subsequently deploying the applications. The SAM CLI includes tools for local development and testing to allow more flexibility in your workflow, permitting local testing of functions in order to iterate quickly.
00:11:14.970 Let's do a quick demo that illustrates what it takes to create a serverless project. We'll initiate a new project with the Ruby 2.5 runtime, ensuring we're using the correct Ruby version for our needs. The SAM CLI provides a fully generated application, even a basic 'Hello World' example, to give you a starting point.
00:11:41.300 As part of our demo, we can see that the tools available make it easy to manage gem dependencies within AWS Lambda, enabling seamless handling of those when deploying applications.
00:12:10.000 Next, we move on to the AWS SDK for Ruby, the project I've been working on for nearly six years now. This SDK supports a significant number of AWS services, providing built-in support for essentials such as pagination and waiters on state changes. The AWS SDK is also modularized, so you only include the gems that you need, supporting efficient handling of dependencies.
00:13:00.760 In version 3.1, the SDK introduces static code generation, improving performance and load times, along with enhanced thread safety, making it suitable for concurrent processes.
00:14:10.000 Additionally, we have the AWS Record gem. One interesting aspect of AWS Lambda is the ability to identify which dependencies can scale effectively. DynamoDB is known for its solid scaling properties and with its fine-grained billing, it allows for both up and down scaling when necessary.
00:15:07.380 The AWS Record gem follows patterns similar to Active Record APIs, allowing for familiar functionality, while also accommodating the specifics of working with DynamoDB, enabling both declarations of data and migrations for consistency.
00:15:59.000 I will briefly demonstrate the ease of implementing declarations through DynamoDB's attributes. Instead of needing to define all attribute types in every context, you can define them once, allowing flexibility in what types of data attributes can hold.
00:16:57.270 Now let's transition to the live demo of a serverless application focused on rating pictures of dogs built with Sinatra. Users can upload dog pictures, which will only go live upon validation through an AWS Lambda function that checks whether the image indeed contains a dog.
00:19:16.000 In this process, an Amazon Recognition service call will filter out any images that are not dogs, automatically handling the upload and display logic without users needing to interact with complex backend processes.
00:20:20.000 After reviewing various examples and the application’s functionality, I encourage you all to try this serverless environment for your own projects. You can find the demo available at a link I will share and try building something similar to showcase the ease and power of serverless with Ruby.
00:21:30.000 As we wind down, I want to thank you all for attending. AWS Lambda, as a compute model, addresses key issues such as elasticity, scalability, availability, security, and fault tolerance when building production applications. By leveraging these managed services, developers can focus more on writing quality code and launch products more quickly, exemplifying the benefits of adopting serverless.
00:22:44.000 Before we wrap up, I recommend checking out related talks on serverless architectural patterns and the evolving landscape of AWS technologies and runtimes, especially those tailored for Ruby.
00:23:58.000 Thank you once again for your time. I'll be around for a bit if you have more questions, and don't forget to grab some stickers from me if you're interested!
Explore all talks recorded at RubyKaigi 2019
+73