Summarized using AI

Serverless Use Cases For Web Projects

Oleksiy Vasyliev • October 19, 2019 • Lviv, Ukraine • Talk

The video titled "Serverless Use Cases For Web Projects" features Oleksiy Vasyliev discussing the practical applications of serverless technology in web development. Serverless computing allows developers to execute code without managing the underlying infrastructure, focusing instead on writing code and eliminating the operational burden of server management. This growing technology has various use cases that can benefit web developers, although it also has limitations and considerations regarding cost and scalability.

Key points discussed in the video include:

  • Definition of Serverless: An overview of serverless computing, highlighting its ability to enable code execution through cloud resources without server management, ideal for developers looking to reduce operational complexity.
  • Support for Programming Languages: Specific mention of Ruby's support on AWS Lambda, the leading provider, while noting the lack of support on Azure and Google Cloud Functions. JavaScript is recommended for its wide platform compatibility.
  • Practical Use Cases:
    • Image Resizing: Utilizing AWS S3 and Lambda functions to automatically resize images upon upload, demonstrating a common and straightforward use of serverless technology.
    • API Gateway for Delayed Resizing: Discussing the use of AWS API Gateway in conjunction with Lambda for managing image resizing requests efficiently, along with associated cost considerations.
    • AWS Lambda@Edge: Explaining how Lambda@Edge can enhance CDN capabilities, enabling dynamic content generation for static websites.
    • Automated SSL Certificate Management: Using Lambda to automate the generation and renewal of SSL certificates through Let's Encrypt and Route 53, showcasing serverless efficiency in managing complex security needs.
  • Challenges and Considerations: The speaker emphasizes challenges such as higher costs when scaling, latency issues due to cold starts of Lambda functions, and the importance of effective monitoring and testing practices within serverless environments.
  • Best Practices: Recommendations include separating input and output buckets to avoid costly loops, diligent cost monitoring, and leveraging tools like AWS CloudWatch for tracking and optimizing performance.

In conclusion, while serverless solutions can streamline operations and reduce costs significantly, careful planning and ongoing management are essential to avoid unexpected expenses and performance issues. Understanding the various use cases and the potential pitfalls is crucial for developers considering adopting serverless architecture in their web projects. The talk also opens the floor for questions, allowing for further exploration of specific concerns raised by the audience.

Serverless Use Cases For Web Projects
Oleksiy Vasyliev • October 19, 2019 • Lviv, Ukraine • Talk

Serverless is very interesting technology, which provides for developer ability to execute a piece of code by dynamically allocating the resources in a cloud. But how exactly it can help you for web development? Wouldn't it be too expensive? Let's look at the practical use cases in this talk.

Pivorak Conf 4.0

00:00:08.870 Hello everyone! My name is Oleksiy Vasyliev. My talk today is about serverless use cases for web projects, exploring how you can use this technology and how it can benefit you. However, there may be cases where it isn't the best fit. I'll also provide some information about myself: I am primarily a web and mobile developer with some experience in DevOps. Additionally, I have contributed to open-source libraries and books, and I host a podcast that focuses mostly on Ruby and JavaScript.
00:00:34.829 Now, let's dive into serverless computing. What is serverless? It's a cloud computing model that allows you to execute code without managing the underlying infrastructure. In this model, you simply write your code, and it is invoked through HTTP requests or other triggers without the need to set up servers. Many developers appreciate serverless architecture because it allows them to focus on writing code, not managing resources.
00:00:48.840 A lot of developers wish to avoid the operational aspects of managing servers. That is why serverless technology is growing, and many companies are transitioning to this setup. However, it's essential to note that you can only move some parts of your infrastructure to serverless. Nonetheless, it remains an exciting technology! Currently, there are numerous serverless solutions available from various cloud providers, including AWS Lambda, Azure Functions, Google Cloud Functions, and many others.
00:01:31.380 Now, let's talk specifically about Ruby. At this conference, we discuss Ruby, and if you look at AWS Lambda, you will see that Ruby is now supported. You can set up your functions in Ruby and run them on AWS Lambda. Azure Functions does not support Ruby at the moment, but with some effort, one can extend its capabilities. Google Cloud Functions currently does not support Ruby either, but AWS is leading the cloud market, continually improving and expanding its services.
00:02:12.240 If you're looking for a language that runs seamlessly across multiple cloud platforms, JavaScript is a strong choice. Almost every platform supports JavaScript or TypeScript, making it an excellent option for serverless functions.
00:02:38.730 Let's explore some practical use cases for serverless technology. One of the most straightforward and popular use cases is image resizing on AWS S3 buckets. For example, when you upload an image, you might want to create thumbnails or resized versions of it. With AWS S3, there are several ways to accomplish this. The process can be initiated through S3 events, AWS API Gateway, or by using AWS Lambda functions.
00:03:34.930 Here's how it typically works: you have a website where users upload images to your S3 bucket. This upload triggers an S3 event, automatically invoking a Lambda function. The Lambda function will then resize the uploaded image and save it back to the same S3 bucket or a different one. This process is straightforward and efficient, as every image uploaded to S3 can be resized accordingly.
00:04:14.470 However, there may be instances where you want to delay the resizing process until a request is made. In such cases, you can use AWS API Gateway along with Lambda to manage the resizing. This setup allows you to serve resized images only when required. With API Gateway, you can route different requests to various services, including Amazon EC2, DynamoDB, Kinesis, or Lambda functions. One thing to be aware of is that the pricing for API Gateway can get expensive, especially with a high volume of requests.
00:05:11.919 The typical flow for using API Gateway involves establishing a link where a user requests an image resize through a URL schema. This URL can specify the desired type of resize, such as cropping or thumbnails. The API Gateway then invokes the corresponding Lambda function, which performs the image resizing and returns the processed image to the client. However, while this approach is interesting and powerful, be mindful of API Gateway costs.
00:06:30.250 Another fascinating application of serverless technology is AWS Lambda@Edge. For those unfamiliar, CloudFront is Amazon's CDN (Content Delivery Network). It is mainly used to serve static content, providing security against certain vulnerabilities by delivering only static HTML, CSS, and JavaScript.
00:08:47.300 Often, there is a need for dynamic content on static websites. Lambda@Edge enables this by injecting a Lambda function that handles requests and responses for static content. There's flexibility in when these functions can be applied: during the viewer request, origin request, origin response, or viewer response phases. By caching responses, you can save on additional requests, which can lead to improved performance and efficiency.
00:09:41.130 For instance, if a user requests an image with a specific format, your Lambda function can check if the image exists in S3. If it's unavailable, it can generate the image, store it in S3 for future requests, and serve it directly to the user. This mechanism allows for lazy evaluation of resources without taxing the system unnecessarily. However, remember that using CloudFront entails specific considerations, especially regarding the routing of URLs.
00:10:57.220 Let's discuss another use case pertaining to HTTPS certificates. Within our lab environments, we often require SSL certificates for various domains, particularly fourth-level domains. Managing these certificates across multiple servers can be burdensome. By utilizing Lambda functions, we can simplify this process. We created a solution that performs wildcard certificate generation using Let's Encrypt and DNS records hosted in Amazon Route 53.
00:12:44.090 This process involves using a Lambda function that accesses the appropriate S3 bucket for certificate storage and supports Route 53 for managing DNS records. Each day, a CloudWatch event triggers our Lambda function, which checks and renews certificates as necessary. This automated system ensures that all necessary certificates remain valid without manual intervention.
00:13:10.150 Additionally, we have an open-source project called Certify, designed for managing serverless SSL certificates. This tool provides a simple command-line utility to allow developers to generate certificates and ensure secure connections using certificates that are valid for limited periods, assisting in maintaining security during remote server access.
00:14:44.732 Serverless architecture has its advantages, including pricing benefits, as you might not need to renew certain certificates monthly, effectively allowing you to remain within the free-tier limits for basic tasks. This setup reduces maintenance efforts and enhances scalability, enabling rapid deployment of services without worrying about server upkeep.
00:15:46.370 Nevertheless, some challenges do arise. For instance, Amazon's lambda functions are sometimes affected by environment changes, which can disrupt functionality. Cost implications can also arise when scaling beyond a specific point, leading to progressively higher bills. Security is another critical concern as you must ensure that your code is secure and that the application itself does not introduce vulnerabilities.
00:16:41.839 From our experience, performance can become tricky in serverless environments. Lambda function warm-up times can add latency especially after periods of inactivity. Developers may resort to using various scheduling techniques such as 'pinging' functions to keep them warm, which might not be ideal. Additionally, the difficulties associated with testing serverless applications locally without a complete replication of the AWS environment can prove tedious.
00:18:06.280 Further testing challenges arise from cost management when operating APIs that handle large volumes of requests. Poor architectural decisions could quickly escalate costs beyond expectations. It is essential to analyze the expected traffic patterns and choose appropriate instances to avoid high bills.
00:19:15.020 For best practices, developers should be wary of how requests from users can incur exponential costs and architect their serverless applications to optimize for efficiency. Utilizing separate buckets for input and output can prevent costly loops that quickly add up. Furthermore, monitoring costs and envelope data is also critical in maintaining your expenditure.
00:20:58.820 Logging and monitoring Lambda usage can provide valuable metrics to optimize performance further. AWS offers tools such as CloudWatch and X-Ray for monitoring execution and resource usage. Building proactive error handling and alerting mechanisms can save time and money down the road, as understanding failed executions can help pinpoint problems more effectively.
00:22:54.560 In summary, using serverless solutions can indeed streamline operations and reduce costs, but careful planning and ongoing management are crucial to avoid overspending or compromising on performance. Many of our choices have come down to meticulous cost analysis and performance evaluations.
00:24:41.600 Thank you very much for your time today; it has been a pleasure to share insights into serverless uses.
00:27:00.990 At this time, I would like to open the floor to your questions. If you have anything to ask, please feel free!
00:27:36.540 The first question raised concern a Lambda function that unexpectedly led to a high bill due to recursive triggers. To clarify, some users mistakenly set up a Lambda to trigger itself, effectively leading to inflation in costs. In contrast, a best practice would be to separate such processes into distinct inputs and outputs.
00:29:41.350 A follow-up question addressed managing infrastructure migration from Lambda functions back to a self-hosted server. Generally, the transition should not be overly complex since the fundamental logic can be extracted into a standard microservice.
00:30:45.030 In response to inquiries regarding tracking execution times, we leverage monitoring solutions like DataDog or Google Stackdriver that collect detailed metrics about the duration and performance of Lambda functions.
00:31:47.639 Lastly, another attendee asked about the feasibility of running Lambdas within a VPC while connecting to RDS instances. The answer confirms that it is possible while ensuring necessary security and performance considerations are addressed.
00:32:51.830 Once again, thank you for joining my talk today, and I look forward to further discussions.
Explore all talks recorded at Pivorak Conf 4.0
+1