Sei sulla pagina 1di 10

Serverless Architecture

Cloud Computing Final Report

Cloud Technologies and Systems (CS5341)

MSc/PG Dip in CS
Department of Computer Science and Engineering,
University of Moratuwa.

Rajind Ruparathna (179349M)


Table of Content
1. Introduction 2

2. What is Serverless Architecture 2

3. Implementation Models of Serverless Architecture 3

4. Serverless Architecture Enabling Technologies 4


4.1. Containers 4
4.2. Container orchestration Platforms 5

5. Benefits of Serverless Architecture 6

6. Drawbacks of Serverless Architecture 6

7. Amazon Lambda 7
7.1. Asynchronous Model Example with AWS 7
7.2. Synchronous Model Example with AWS 8

8. Conclusion 8

9. References 9

1
1. Introduction
Cloud Computing is gradually taking over the world and it is becoming a technology that the
industry cant live without. This comes as no surprise as with the business drivers such as
capacity planning, cost reduction and organizational agility, Cloud Computing has become
the most prefered choice for most organizations. One of the main concepts of Cloud
Computing is that the technology is abstracted away from the user, which basically means
that the users does not have to worry about how the cloud service is provided and they can
simply focus on using the cloud services. Having this concept in mind cloud providers try to
provide everything as a service and so far the main delivery models are Infrastructure as a
Service (IaaS), Platform as a Service (PaaS) and Software as a Service (SaaS).

It is the advancement of technologies such as broadband networks and internet architecture,


data center technologies, virtualization, web technologies, multitenant technologies and
service technologies which made way for Cloud Computing and with new changes and
technologies coming in new Cloud Computing trends and delivery models are emerging as
well. One of those trending cloud delivery models is Function as a Service (FaaS) which is
also known as Serverless Architecture. In this report we will mainly look at the Serverless
Architecture, different models of using Serverless Architecture, enabling technologies of
serverless architecture and Amazon Lambda which is one of the major Function as a
Service providers.

2. What is Serverless Architecture


The term serverless is a bit misleading. This does not mean that servers are no longer
required and it basically goes with the concept of abstracting technology away from the user.
The users no longer have to worry about servers and someone else (the cloud provider) is
taking care of all that for the user. The serverless term has been used for two different
meanings. One is that it was used to describe applications that significantly or fully depend
on 3rd party applications services in the cloud to manage server-side logic and state. These
systems are mostly rich client applications which largely depend on cloud services such as
cloud accessible databases, authentication services, etc. These types of services have been
previously described as Backend as a Service (BaaS).

The other and the more recent use of this term is to the refer the applications where some
amount of server-side logic is still written by the application developer but unlike traditional
architectures, this is run in stateless compute containers that are event-triggered, ephemeral
(may only last for one invocation), and fully managed by a 3rd party. That is where the term
Function as a Service (FaaS) comes in and both these terms the FaaS and Serverless
Architecture became popular with the AWS Lambda[1] launch in 2014 and even more so
after Amazons API Gateway[2] launched in July 2015. AWS Lambda is the most popular

2
FaaS provider today and others like Google Cloud Functions[3] are becoming popular as
well. These will be discussed further in coming sections.

Going into a bit more detail of the features of Serverless Architecture and FaaS, the first one
is that it allows users to write custom server-side function and run it accordingly. It is not a
very huge amount of code unlike the case where an application is developed on a PaaS. It is
a function which is specific to a certain small task. One such example would be creating a
thumbnail from an image or perhaps running a database query. These examples will be
further discussed in coming sections. FaaS offerings do not require coding to a specific
framework or library. FaaS functions are regular applications when it comes to language
and environment.

Serverless Architecture is event triggered. Its architectured in a such a way that there has
to be an event source which triggers the service to run. When comparing with other cloud
delivery models, this is not something we see in these other models. This is specific to FaaS.
Another feature is that FaaS is ephemeral and what it means is that the execution of the
service may lasts a very short time. Unlike in a case like SaaS or PaaS for that matter where
service is running continuously, in FaaS the service may only run for a very short time period
for a given trigger and thats it. Of course there is some sort of a service running to monitor
the incoming triggers but the computing service is not continuously running for long time
periods. Along with this with FaaS horizontal scaling is completely automatic, elastic, and
managed by the provider. If a user requires a system which can process 100 requests in
parallel the cloud provider will handle that automatically and user dont need to give any sort
of extra configuration for this.

Another quality of FaaS is that it is stateless. Persisting state between two executions of
the same function is not possible in the general design. In cases where storing state is
required it should be stored externally.

3. Implementation Models of Serverless


Architecture
A serverless platform allows users to run their applications including computing, storing, and
networking without the need for spinning up and managing a single machine. Being able to
focus on software development without worrying about managing a cluster of servers is the
primary driver behind serverless. Some of the use cases of of serverless can be as follows.

Collecting metrics from web application with a REST API in a high load scenario.
Extracting and storing data from incoming emails containing order and status
information.
Creating a REST API providing a standard CRUD backend.
Collecting and transforming data within an ETL process in a big data scenario.
Analyzing log messages from a real-time data stream.

3
Building a chatbot that is interacting with multiple APIs in the background.

In these various use cases depending on the requirement an asynchronous serverless


model or a synchronous serverless model can be used. In an asynchronous scenario, the
caller does not wait until the function returns. Notifications via WebSocket or push
notifications to a mobile device can be used to provide feedback to the user. One example
for this would be a mobile app requesting a thumbnail of an image for the user profile. In the
synchronous scenario as the name suggests the caller will wait for a response from the
function. One example would be an HTTP call which is supposed to query a database and
return the results.

4. Serverless Architecture Enabling Technologies


Underneath the FaaS model, how the user code is executed is using the container model.
So once a trigger comes in the cloud provider takes care of provisioning and managing
resources and it launches a container to run the code based on the configuration setting
provided by the user. Once the execution is done the usual practise of most of the cloud
providers is to wait a certain amount of time to see if another trigger comes in and if not the
container is stopped. This is the overall idea on how a serverless system works.

There are a number of FaaS providers today, some proprietary providers such as AWS
Lambda[1], Google Cloud Functions[3], Azure Functions[4] and some open source ones
such as OpenWhisk[5]. Looking at the technologies that made FaaS possible, two major
technologies are the containers and container orchestration technologies.

4.1. Containers

Containers are a new type of virtualization and they fall under the category of operating
system level virtualization. Containers share the underlying kernel of the host operating
system and they allow multiple isolated user-space instances (containers). Today there a
number of container platforms such as Docker[6], LXD[7] and out of those Docker is the
most widely used platform. Following diagram shows the above mentioned container
architecture with Docker.

4
Figure 1 : Docker Container Architecture.
Image taken from [8]

When we compare virtual machines (VM) with containers there are several advantages that
container bring to the table. One is that unlike in VMs containers usually impose little to no
overhead ensuring most of the machines resources are available to the applications running
in containers. Along with that one of the important point in which containers beat VMs is the
time to startup and shutdown. Containers can be taken up and down in a matter of seconds
whereas VMs take a lot more time than that. Containers get this advantage due to the fact
that they share the host OS kernel. Having faster up and down times makes containers ideal
for FaaS due to the trigger driven architecture FaaS. Along with the above mentioned
advantages containers do have a few disadvantages as well. One is that it limits the
operating system choice of virtualization. The issue here is that the guest operating system
must be identical or similar to host operating systems. However this the container platforms
have now induced mechanisms to minimize this issue somewhat as well.

4.2. Container orchestration Platforms

A single container by itself is not very much useful. In enterprise applications managing of
clusters of containers is required. Container orchestration platforms extend lifecycle
management capabilities to complex, multi-container workloads deployed on a cluster of
machines. These platforms abstract the host infrastructure and allow users to treat the entire
cluster as a single deployment target. Basic features of container orchestration tools
includes ability to automate all aspects of application management from initial placement,
scheduling and deployment to steady-state activities such as update, deployment, and
health monitoring functions that support scaling and failover. There are dozens of container
orchestration platforms such as Kubernetes[9], Docker Swarm, Mesosphere Marathon and
some of them provided as cloud solutions such as AWS Elastic Container Service (AWS
ECS), Google Container Engine and Azure Container Service (ACS).

5
5. Benefits of Serverless Architecture
This section will focus on the benefits that Serverless Architecture or FaaS brings. First and
foremost benefit is the reduced operational cost FaaS provides. This benefit is not too
different from what we get for other cloud delivery models such as IaaS or PaaS however
depending on the application FaaS can be more advantageous than the other two. One such
application is an application which get occasional requests. In such a scenario, unlike in
PaaS or SaaS users dont have to keep the servers up and running 24/7 and with FaaS they
only have to pay for the actual computation that is required. Another instance where FaaS is
better is when the traffic is highly inconsistent or spiky perhaps. In cases like these, if it is
PaaS or IaaS the average number of servers users have to keep up an running is much
larger because handling spikes is not easy with those solutions with VMs. Therefore in these
cases FaaS is much better as horizontal scaling is completely automatic, elastic, and
managed by the provider. Scaling benefits by itself can be mentioned as an advantage of
FaaS since scaling is performed by the provider on every request / event and the user no
longer need to even think about the question of how many concurrent requests the system
can handle before running out of memory or seeing too much of a performance hit, at least
not within the FaaS hosted components.

Another advantage we can have with FaaS is reduced packaging and deployment
complexity. FaaS function is very simple compared with an entire server. For a user who is
just getting started, he/she may not even need to package anything and just code in the
FaaS providers console. Along with these with FaaS time to market is much less as well and
experimentation is much more quicker.

6. Drawbacks of Serverless Architecture


In the previous section we looked at the benefits FaaS brings to the table. However we
should know that these comes with a few trade-offs as well. One would be vendor control.
What this means is that with FaaS user gives complete control of the system to a 3rd party
vendor. This lack of control may result in system downtimes, unexpected limits, cost
changes, loss of functionality, forced API upgrades, and more. FaaS could also have
multi-tenancy problems. Multi-tenancy problems are not specific to FaaS and those are
there is almost all the cloud delivery models as well but since FaaS is new this could have a
bigger impact. Another problem is vendor lock-in. Again this is not specific to FaaS and this
is common to almost all cloud services. The quality of FaaS being stateless could also be a
drawback in certain cases where the developers have to depend on external system to save
the state if required.

6
7. Amazon Lambda
AWS Lambda is the most popular FaaS provider and in fact it is AWS who brought the
Serverless Architecture term into the market with the release of Amazon Lambda in 2014. In
Lambda users can use events such as an update to Dynamo DB, uploads to Amazon S3
bucket, data in Amazon Kinesis streams or even in-app activity as triggers for the Lambda
functions. Lambda provides the computing infrastructure and a runtime environment for
JavaScript (Node.js), Java, Python, and .NET Core (C#). I n AWS users are charged for
every 100ms their code executes and the number of times the code is triggered.

7.1. Asynchronous Model Example with AWS

In this section we will look at one use case of AWS Lambda which uses the asynchronous
model. The scenario is that user wants to create a thumbnail of image uploaded to Simple
Storage Service (S3) bucket.

Figure 2 : Asynchronous Serverless Architecture with AWS.


Image taken from [10]

1. The mobile application is uploading an image to an object store.


2. The object storage is creating a change event after the image was uploaded,
resulting in an execution of a serverless function.
3. The serverless function creates a thumbnail based on the uploaded image. After
uploading the thumbnail on the object storage.
4. The serverless function sends a push notification to the mobile application.
5. The mobile application downloads the thumbnail and updates the user interface
accordingly.

7
7.2. Synchronous Model Example with AWS

A typical use case for the synchronous model is a REST API. An incoming HTTPS request is
triggering a serverless function. The caller waits until the function returns a result.

Figure 3 : Synchronous Serverless Architecture with AWS.


Image taken from [10]

1. The client sends an HTTPS request to an API Gateway.


2. The API Gateway triggers a serverless function.
3. The serverless function reads data from a NoSQL database.
4. Afterwards the serverless function returns the result of the database call to the client.

8. Conclusion
FaaS concept is still very new and it is a concept which is yet to be proven in large scale
enterprise applications. There is still room for FaaS to improve and its drawbacks. One area
where they could improve is tooling. The lack of tooling for deployment, application
bundling, configuration, monitoring, logging and debugging is an issue which need to be
addressed. Another such area for improvement is state management. Even without state
FaaS is pretty good for many applications but there can be cases where storing state
externally might not be enough and perhaps require state to be stored within functions. Its
obvious that Serverless Architecture is not the option for every scenario or problem but it is
clear that with the benefits it provides there is a significant interest throughout the industry
for Serverless.

8
9. References
[1] AWS Lambda - Serverless Compute [Online]. Available :
https://aws.amazon.com/lambda/
[2] Amazon API Gateway [Online]. Available : https://aws.amazon.com/api-gateway/
[3] Cloud Functions - Serverless Environment to Build and Connect Cloud Services | Google
Cloud Platform [Online]. Available : https://cloud.google.com/functions/
[4] Azure FunctionsServerless Architecture | Microsoft Azure [Online]. Avaliable :
https://azure.microsoft.com/en-us/services/functions/
[5] Apache OpenWhisk is a serverless, open source cloud platform [Online]. Available :
http://openwhisk.org/
[6] Docker - Build, Ship, and Run Any App, Anywhere [Online]. Available :
https://www.docker.com/
[7] Linux Containers - LXD - Introduction [Online]. Available : https://linuxcontainers.org/lxd/
[8] For CTOs: the no-nonsense way to accelerate your business with containers, 2017.
[9] Kubernetes | Production-Grade Container Orchestration [Online]. Available :
https://kubernetes.io/
[10] A. Wittig, The DZone Guide to Cloud Native Development & Deployment Volume IV -
Serverless Architectures on AWS 2017.

Potrebbero piacerti anche