AWS Professional - Devops | Machine Learning | Cyber Security
Serverless has been getting a lot of attention among web application developers and business owners this year. The major selling point of serverless has been the speed of execution and the ease of API deployment.
In this article, we will look at what exactly the serverless architecture is along with the pros and cons of using serverless to design your next web / mobile application.
Serverless doesn’t mean running an application without a server, but not having a server to manage. The Serverless model automatically scales up and down based on user requests, easing the effort involved in managing backend architectures.
Typical web application backends require a server where you would host your application along with a database. As the user base grows, your backend starts to consume a higher percentage of resources. You will have to hire backend engineers and buy more space & computing power in order to accommodate those incoming requests.
With Serverless platforms like AWS Lambda, you would deploy each API in a microserver, and Lambda will automatically scale the API based on incoming traffic. A simple use case would be a GET request that fetches data from the database and returns the data back to you as JSON.
If you are familiar with Platform-as-a-service(PaaS) architectures like Heroku and Elastic Beanstalk, Lambda is essentially a Function-as-a-service architecture. While PaaS platforms relive a lot of infrastructure complexities, FaaS platforms take it a step further and handle the complete backend architecture.
Auto Scaling: Lambda can scale up and down automatically without any manual intervention. If your app has a sudden surge of a million visitors, Lambda got you covered.
High Concurrency: Lambda is highly concurrent as well. Lambda can handle up to 3000 requests concurrently with an additional 500 requests every second.
Reduced Operational Costs: Lambda was designed to bring costs down. Companies like A Cloud Guru have been using Lambda as part of their core architecture, cutting considerable amounts in server expenses.
Even though Serverless computing is a great model, it is not for everyone. Let's look at some of the limitations of the serverless architecture.
No Environment Control: Since the serverless system is fully automated, you don't have any control of the environment your code runs in. You will not be able to store anything in memory and will have to use other tools like ElastiCache.
Hard Timeouts: Lambda enforces a 5-minute hard timeout. If your code execution takes longer than 5 minutes, Lambda will stop the execution and return a timeout. This makes complex tasks involving third party data not suited for Lambda.
No Internal Networking: Lambda functions can be accessed only as APIs. If your application backend has a lot of internal communication between functions or modules, a serverless model will not be the right choice for you.
Serverless is a brilliant computing model that is taking over the world of backend services and RESTful APIs. However, it does come with its own advantages and disadvantages. Understanding those tradeoffs is important to design better a backend architecture for your next product/service.