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

  1. Invocation : A single function execution.

  2. Duration: the amount of time a function takes to execute.

  3. Cold Start: The amount of time a function takes when it is triggered for the first time.

  4. Concurrency Limit: The number of functions that can run simultaneously in one region. A function will be killed if it exceeds this limit.

  5. 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

  1. Infrastructure Management

    • Serverless Architecture: fully managed by the cloud provider.

    • Container Architecture: developers manage the container runtime and orchestration.

  2. Cost Model

    • Serverless Architecture: Pay-per-use

    • Container Architecture: Pay for allocated resources (CPU, Memory)

  3. Flexibility

    • Serverless Architecture: Limited control over runtime environment.

    • Container Architecture: Full control over OS, runtime dependencies.

  4. Scalability

    • Serverless Architecture: Automatic and event-driven

    • Container Architecture: Manual or automated with orchestration tools.

Benefits of Serverless Architecture

  1. 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.

  2. Scalability

    • Serverless applications automatically scale with the number of requests.

    • Cloud providers manage the scaling, allowing the application to handle varying loads seamlessly.

  3. 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