Imagine that a critical application in your company is having performance issues. This application is available to customers 24–7, and during business hours, the CPU and memory utilization reaches 100%. This is resulting in increased response time for customers. Around 10 years ago, a good migration plan to solve this issue would involve the procurement and deployment of new hardware resources for both the application and its databases, the installation of all required software and application code, performing all functional and performance quality analysis work, and finally, migrating the application. The cost of this would run into millions.
However, nowadays, this issue can be resolved with new technologies that offer different approaches to customers — going Serverless is definitely one of them. In this lesson, we’ll start with an explanation of the serverless model, and get started with AWS and Lambda, the building blocks of serverless applications on AWS. Finally, you’ll learn how to create and run Lambda functions.
The Serverless Model
To understand the serverless model, let’s first understand how we build traditional applications such as mobile applications and web applications.
Above diagram shows a traditional on-premises architecture, where you would take care of every layer of application development and the deployment process, starting with setting up hardware, software installation, setting up a database, networking, middleware configuration, and storage setup.
Moreover, you would need a staff of engineers to set up and maintain this kind of on-premises setup, making it very time-consuming and costly. Moreover, the life cycle of these servers was no longer than 5–6 years, which meant that you would end up upgrading your infrastructure every few years. The work wouldn’t end there, as you would have to perform regular server maintenance, including setting up server reboot cycles and running regular patch updates. And despite doing all the groundwork and making sure that the system ran fine, the system would actually fail and cause application downtime.
The serverless model changes this paradigm completely, as it abstracts all the complexity attached to provisioning and managing data centers, servers, and software. Let’s understand it in more detail. The serverless model refers to applications in which server management and operational tasks are completely hidden from end-users, such as developers.
In the serverless model, developers are dedicated specifically to business code and the application itself, and they do not need to care about the servers where the application will be executed or run from, or about the performance of those servers, or any restrictions on them. The serverless model is scalable and is actually very flexible. With the serverless model, you focus on things that are more important to you, which is most probably solving business problems. The serverless model allows you to focus on your application architecture without you needing to think about servers.
Sometimes, the term “serverless” can be confusing. Serverless does not mean that you don’t need any servers at all, but that you are not doing the work of provisioning servers, managing software, and installing patches. The term “the serverless model” just means that it is someone else’s servers. Serverless architectures, if implemented properly, can provide great advantages in terms of lowering costs and providing operational excellence, thus improving overall productivity.
However, you have to be careful when dealing with the challenges imposed by serverless frameworks. You need to make sure that your application doesn’t have issues with performance, resource bottlenecks, or security. Below diagram shows the different services that are part of the serverless model. Here, we have different services for doing different kinds of work. We have the API Gateway service, a fully managed REST interface, which helps to create, publish, maintain, monitor, and secure APIs. Then, we have the AWS Lambda service that executes the application code and does all the computation work. Once the computation is done, data gets stored in the DynamoDB database, which is again a fully managed service that provides a fast and scalable database management system. We also have the S3 storage service, where you can store all your data in raw formats that can be used later for data analytics.
Want to discover more about real-time data streaming and other AWS services, check out today about my new book on “serverless architectures with AWS” at https://amzn.to/2kuEbgi