Serverless architecture
Serverless architecture is a cloud computing execution model where the cloud provider dynamically manages the allocation and provisioning of servers. It is an approach to software design to build and run services without the need to manage the underlying infrastructure.
How Serverless Architecture works
Servers allows users to with an application but it is very difficult to manage servers as it consumes a lot of time and resources. Therefore, by adopting serverless architecture, developers can focus only on writing application code.
One of the most popular serverless architecture is Function as a Service(FaaS), where
Developers write functions, which are small units if logic that perform a single task.
Functions are triggered by events such as HTTP requests, database changes, or message queues.
There is also Backend as a Service(BaaS), where
services like databases, authentication, and storage are managed by the cloud provider.
Firebase, AWS DynamoDB, etc.
Terminologies in Serverless architecture
Invocation : A single function execution.
Duration: the amount of time a function takes to execute.
Cold Start: The amount of time a function takes when it is triggered for the first time.
Concurrency Limit: The number of functions that can run simultaneously in one region. A function will be killed if it exceeds this limit.
Timeout: The amount of time a function is allowed to run before termination. Most providers (cloud) set a default and a maximum timeout.
Serverless Architecture Vs Container Architecture
Both the architectures allow developers to deploy application by abstracting away the host environment, but there are some differences, say like developers who are using container architecture have to update and maintain each container they deploy. Whereas, maintaining server in serverless architecture is handled fully by cloud provider.
Comparison between Serverless architecture and Container architecture
Infrastructure Management
Serverless Architecture: fully managed by the cloud provider.
Container Architecture: developers manage the container runtime and orchestration.
Cost Model
Serverless Architecture: Pay-per-use
Container Architecture: Pay for allocated resources (CPU, Memory)
Flexibility
Serverless Architecture: Limited control over runtime environment.
Container Architecture: Full control over OS, runtime dependencies.
Scalability
Serverless Architecture: Automatic and event-driven
Container Architecture: Manual or automated with orchestration tools.
Benefits of Serverless Architecture
Cost Efficiency
It is fully pay-per-use. There is no charge when your code is not running.
It also reduces operational costs as there is no need to provision or manage servers.
Scalability
Serverless applications automatically scale with the number of requests.
Cloud providers manage the scaling, allowing the application to handle varying loads seamlessly.
Improved Resilience
Serverless architectures often have built-in redundancy and fault tolerance.
Functions are typically distributed across multiple regions and availability zones.
Use Cases
Microservices and API backends
Event-driven data processing
Real-time file processing
IoT data processing
Chatbots and voice assistants