What is Serverless Architecture? – Part One

Serverless architecture is the architecture in which your apps are hosted on a cloud platform provided by a cloud provider. This process eliminates your need for server management which includes software or hardware management or both. Your application will still run on servers but will be broken down into individual logical functions that can be invoked and scaled when needed. This will allow developers to write code and deploy it on the server managed by a cloud provider which will also manage the database and storage system that can be provisioned and scaled when needed.

How Does Serverless Architecture Work?

Servers allow clients to communicate with their application through a trigger that can be an email or an HTTP request. But managing servers that include hardware and software management, scaling up when the load increases, and scaling down when the minimum load can be very difficult and requires an extra amount of resources. And then when you have to upgrade the system, the security updates can be a hectic task.

By adopting serverless architecture, developers can offload the burden of managing servers and can really work on developing their applications.

Types of Serverless Architecture:

Serverless computing typically falls into two groups: Backend-as-a-service (BaaS) and Function-as-a-service (FaaS).

Backend-as-a-Service (BaaS)

BaaS provides developers with many third-party services and applications that can be used through APIs. For example, your cloud provider can provide pre-configured authentication services or data encryption services, etc.

Function-as-a-Service (FaaS)

In FaaS, developers can write custom server-side logic in the form of unique functions, but it’s run in containers fully managed by a cloud services provider. The functions will be invoked by a trigger. A trigger can be anything from an incoming email to an HTTP request or a database operation. When a function is invoked, the cloud provider either executes the function on a running server or, if there is no server currently running, it provisions a new server to execute the function. This execution process is hidden away from the developers, who can focus on writing and deploying the application code.

Serverless architecture is around for a decade now, Amazon introduced their first FaaS architecture in the form of AWS Lambda in 2014 followed by Google and Microsoft with their Google Cloud Platform and Azure Functions respectively.

Some Common Concepts in Serverless Architecture

Although serverless eliminates your need for managing servers, there are still many things that you have to learn and keep in mind while implementing. In serverless, you are writing multiple functions and linking them together to form a complex workflow in your application. It can therefore be helpful to learn some common serverless terms.

Invocation: When a single function is executed, it is called Invocation.

Duration: The time taken by a serverless function to execute is called Duration.

Cold Start: When a function is invoked after some time of inactivity then it results in a latency of some seconds. This latency is called a cold start.

Concurrency Limit: Concurrency limit is the number of functions a cloud provider allows you to run in a region. If the number of functions exceeds this limit then the functions are throttled.

Timeout: This is the amount of time the cloud provider allows your function to run.

Serverless vs Container Architecture

Serverless and container architectures, both, allow developers to deploy their code without worrying about the environment and server, but there are some differences.

In container architecture, developers have to update and maintain each container themselves that including all system settings and dependencies. Contrarily, in serverless architecture, server maintenance is entirely handled by the cloud provider. Additionally, serverless apps scale automatically, while scaling containers require the use of a platform like Kubernetes.

Containers give developers control over the underlying operating system and runtime environment, making them suitable for applications that consistently get high traffic or as a first step in cloud migration. Serverless functions, on the other hand, are best for trigger-based events like implementing hooks in a payment processing app, etc.

AWS Serverless Architecture

AWS offers many technologies for Serverless architecture from running code to managing the data and integrating applications with other services, all without having to worry about server management. These technologies feature auto-scaling, high availability, and the billing model that is called pay-for-user which increases agility and optimizes your costs. These technologies also provide infrastructure-level management tasks like provisioning more functions in need and removing extra provisions after the load is decreased so you can focus on writing code that serves your application needs. AWS started its serverless applications in 2014 with AWS Lambda. AWS Lambda is a computing service that is event-driven and was first natively integrated with over 200 AWS services and SaaS applications.

Serverless Services on AWS

Following are the serverless services provided by AWS:

Computing

  • AWS Lambda: AWS Lambda is an event-driven, pay-as-you-go compute service that lets you run code without managing servers.
  • AWS Fargate: This is a compute engine used for serverless that can integrate with Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). 
  • Amazon EventBridge: EventBridge is a serverless event bus that lets you build event-driven applications at scale across AWS and existing systems.
  • Amazon SQS: Simple Queue Service (SQS) is a message queueing service enabling you to decouple and scale microservices, distributed systems, and serverless applications.
  • Amazon SNS: Simple Notification Service (SNS) is a fully managed messaging service for both a-2-a and a-2-p communication.
  • Amazon API Gateway: To create and publish APIs easily, Amazon introduced API Gateway that is fully managed by AWS.
  • AWS AppSync: AWS AppSync accelerates application development with scalable GraphQL APIs.

Datastore

  • Amazon S3: Amazon Simple Storage Service (S3) is designed to store objects in any amount
  • Amazon DynamoDB: Amazon DynamoDB is a key-value and document stored database designed to deliver single-digit millisecond performance on any scale
  • Amazon RDS Proxy: It is a managed database proxy designed for RDS to make applications more scalable and secure
  • Amazon Aurora Serverless: It is a MySQL or PostgreSQL-enabled database service designed to scale based on your application’s needs.

Looking for a Development Team?

Share the details of your request and we will provide you with a full-cycle team under one roof.

Get an Estimate

Pros and Cons of Serverless Architecture

Pros

Serverless architecture is being used in many small and big size companies due to following reasons:

  • Cost
    Cloud providers charge you on a per-invocation basis so you are not paying for unused servers.
  • Scalability
    Functions are automatically created and removed as a result of an increase or decrease in traffic.
  • Productivity
    Developers using serverless can just deploy their code without thinking of managing any servers. This helps accelerate the delivery and scale operations of the company.

 

Cons

While there are some amazing benefits of using serverless, there are also some challenges that developers face while using/implementing serverless architecture:

  • Cold Start
    While working with serverless architecture, the cold start is the most common issue that you are going to face. Cold starts can add multiple seconds in executing a function when it is invoked after inactivity.
  • Security
    The cloud provider runs the codes of multiple customers on the same shared server. So if the server is not configured properly, you can face some security issues.
  • Loss of Control
    While working in the serverless architecture, we don’t have control over the server’s software or hardware. So if the problem occurs on the server level, we have to wait for the cloud provider to fix it.

Serverless Architecture Use Cases

Serverless architecture is used to perform short-lived tasks and manage workloads with unpredictable traffic. The main use cases include:

Asynchronous Programming

Serverless architecture is best used for asynchronous tasks. It handles behind the scene tasks amazingly. So if you are processing some image or processing a video after upload that you don’t want the user to know and just complete silently, serverless architecture is the most suitable for you.

Trigger-based tasks

Any user activity that triggers a function is most-suitable for serverless architecture. For example, if you have a server signup that triggers a database change and you want to send a welcome email, you can achieve it easily with serverless architecture.

Building RESTful APIs

You can use AWS API Gateway with serverless functions to build a bunch of RESTful APIs that scale with demand.

Now let’s move on to the next part “Deploying Django Apps in Serverless Using Zappa

Share this article

Related Posts