Serverless architectures refers to applications that significantly depend on third-party services known as Backend as a Service or “BaaS”. Do not be misled by the name as it does not actually involve running code without servers. The name “serverless computing” is used because the organization that owns the system does not have to purchase, rent or provision physical servers or virtual machines for the back-end code to run on.
Serverless architecture can be a benefit in terms of reducing the operational cost. AWS Lambda is a serverless architecture that allows developers to create and configure a small function AWS console and execute the code without the need to provision physical or virtual servers and paying only for the resources used during the execution.
Benefits of Serverless Architecture
- No need to maintain the server
- Pay only for the code compute time
- AWS Lambda manages continuous scaling
How It Works
- Write the code in AWS Lambda supported language
- Configure other services (Scheduler, HTTP, HTTPS) to trigger the code
- Lambda executes the code when triggered
Why Need Serverless Architecture
To host a software application involves at least a server infrastructure (either a cloud or physical server) with the operating system and other configurations required to run the application. Using a serverless architecture, the development team can focus solely on the business logic in the application code without worrying about server infrastructure and scaling needs. AWS Lambda takes care of all the virtual machine operating systems etc.
Who should use serverless
- Applications that are event-driven
- On-premise is not the Deployment target
- Application state can be captured externally (not in memory)
- Application Startup time is minimal
- Small number of functions
AWS Lambda function is supported by the following languages:
Lambda Function Requirements
- A Handler – An entry point for Lambda. A Lambda function accepts JSON-formatted input and returns the output in the same format.
- Runtime environment – The runtime correlates directly with the language, which is selected to write the function.
- A Trigger – Configuring a Lambda invocation in response to an event.
- Whenever a new request is invoking from either web/mobile/scheduler/database, a dedicated API Gateway triggers a Lambda function which initializes the process.
- Lambda function executes the code to perform the business logic.