Skip to content

Introduction to Serverless

What is serverless computing

Serverless computing is a cloud-computing model that can reduce complexity in deploying code into production. It's called "serverless" not because there are no servers, but because you don't have to manage them. The cloud provider handles the routine tasks of provisioning, maintaining, and scaling the infrastructure.

Different Types of Serverless Computing Services

Serverless computing is a cloud computing execution model in which the cloud provider manages the server infrastructure and dynamically allocates resources to the application as needed. This allows developers to focus on writing code without having to worry about managing servers.

You can see below for the cloud provider Google how they divide the types of cloud services they propose :

Nowadays, there's a rising variety of cloud offerings that facilitate the creation of more budget-friendly applications with enhanced efficiency and simpler scalability.

These include Infrastructure as a Service (IaaS), Platform as a Service (PaaS), Function as a Service (FaaS), and Software as a Service (SaaS). If you're in search of a comprehensive framework solution for your enterprise, you've probably encountered terms like Serverless and Docker Containers.

These terms correspond to the FaaS and PaaS models, respectively. Many specialists currently view these methods as top-tier strategies in cloud computing due to their straightforwardness and adaptability in app creation and launch. Yet, there are distinct differences between them, which we'll see today.

Key Concepts

There are two main types of serverless computing services:

  • Function as a Service (FaaS): FaaS services allow developers to run code on-demand without having to provision or manage servers. The cloud provider automatically scales the resources up or down based on the workload. Popular FaaS services include AWS Lambda, Azure Functions, and Google Cloud Functions.
  • Backend as a Service (BaaS): BaaS services provide developers with a set of pre-built backend services, such as databases, authentication, and storage. This allows developers to quickly and easily build and deploy web and mobile applications without having to write any backend code. Popular BaaS services include Firebase, AWS Amplify, and Azure Mobile Apps.

In addition to FaaS and BaaS, there are a number of other types of serverless computing services, including:

  • Serverless databases: Serverless databases are fully managed databases that automatically scale up or down based on the workload. Popular serverless databases include Amazon Aurora Serverless, Amazon DynamoDB, and Google Cloud Spanner.
  • Serverless messaging: Serverless messaging services allow developers to send and receive messages between applications without having to manage any infrastructure. Popular serverless messaging services include Amazon Simple Queue Service (SQS), Amazon Simple Notification Service (SNS), and Google Cloud Pub/Sub.
  • Serverless event processing: Serverless event processing services allow developers to process events from a variety of sources, such as databases, IoT devices, and web applications. Popular serverless event processing services include Amazon Kinesis, Azure Event Hubs, and Google Cloud Dataflow.

Serverless computing services can be used to build a wide variety of applications, including:

  • Web applications
  • Mobile applications
  • APIs
  • Microservices
  • Data processing applications
  • Event-driven applications

Some benefits

Serverless computing offers a number of benefits, including:

  • Agility: Serverless computing makes it easy to quickly deploy and scale applications.
  • Cost-effectiveness: Serverless computing is a pay-as-you-go model, so you only pay for the resources that you use.
  • Reliability: Serverless computing services are highly reliable and scalable.
  • Security: Serverless computing services are built with security in mind.

Serverless computing is a powerful and flexible cloud computing model that can be used to build a wide variety of applications. By understanding the different types of serverless computing services available, you can choose the services that are best suited for your needs.

Serverless Microservices & Docker

First, Serverless computing and Docker are both cloud computing technologies, but they have different advantages and disadvantages and they share minimal similarities.

Serverless computing is a cloud computing execution model in which the cloud provider manages the server infrastructure and dynamically allocates resources to the application as needed. This allows developers to focus on writing code without having to worry about managing servers.

Docker is a containerization platform that allows developers to package their code and all its dependencies into a standalone container that can run on any operating system. This makes it easy to deploy and manage applications across multiple environments.

Differences and similarities

Some shared characteristics include:

  • Reduced overhead
  • Optimal performance
  • Limited need for infrastructure setup

The main difference between serverless computing and Docker is that serverless computing is a managed service, while Docker is a self-managed technology. With serverless computing, the cloud provider is responsible for managing all of the infrastructure, including servers, storage, and networking. With Docker, the developer is responsible for managing the infrastructure that their containers run on.

Another difference between serverless computing and Docker is that serverless computing is event-driven, while Docker is not. With serverless computing, code is executed in response to events, such as HTTP requests or database changes. With Docker, containers can be run on a schedule or manually. Micro service - docker and serverless

Build & deploy together

Serverless computing and Docker can be used together to build and deploy applications. For example, developers can use Docker to package their code into containers and then deploy those containers to a serverless computing platform like Google App Engine or Microsoft Azure App service.

This allows them to take advantage of the benefits of both technologies, such as the scalability and cost-effectiveness of serverless computing and the portability and flexibility of Docker.

Traditional VS Serverless Architectures

Let's consider a simple flask web application in python in order to compare the Traditional (or Monolith) architecture with Serverless.

Traditional Architectures:

  • Infrastructure Management: You're responsible for setting up, configuring, and maintaining servers.
  • Scaling: Manual or requires complex auto-scaling configurations.
  • Cost: Pay for pre-allocated resources, regardless of usage.
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()

For run this code you will need to set up a server, deploy this Flask app, handle scaling, and manage server downtimes, https security... I think you know what I mean 😅

Serverless Architectures:

  • Infrastructure Management: Handled by the cloud provider.
  • Scaling: Automatic scaling based on the number of requests.
  • Cost: Pay only for the actual compute time.

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': 'Hello, Serverless!'
    }
This function can be deployed to AWS Lambda, and AWS will handle the scaling, maintenance, and execution and your other security concerns 😂

Or for the google cloud function version :

def hello_world(request):
  """A simple serverless function that returns a greeting."""

  return 'Hello, world!'

Then you can deploy the function to Google Cloud Functions using the following command:

gcloud functions deploy hello_world --runtime python37

Once the function is deployed, you can invoke it using the following curl command into your terminal :

curl -X POST https://[YOUR_CLOUD_FUNCTIONS_REGION]-[YOUR_CLOUD_FUNCTIONS_PROJECT_ID].cloudfunctions.net/hello_world

Do not worry about the code you just saw, we will dive into cloud function in our next section.

Here are some of the major cloud providers that offer cloud function services:

  • Amazon AWS Lambda
  • Microsoft Azure Functions
  • Google Cloud Functions
  • IBM Cloud Functions
  • Oracle Cloud Functions

Conclusion

Serverless computing is a powerful and flexible cloud computing model that can be used to build a wide variety of applications. By understanding the different types of serverless computing services available, you can choose the services that are best suited for your needs.

I think the great deal you have by learning Serverless Computing as a developper is that you can easily build pipelines even you are not very familiar with high tech concept like load balancing or messaging. Almost all Serverless solutions support event triggers, which means they are great for pipelines and sequenced workflows.