Serverless Architectures The Evolution of Cloud Computing
Serverless Architectures The Evolution of Cloud Computing
Summary 7
Resources 7
Introduction
1
operating system, are abstracted away from the developer.
Applications are run in stateless compute containers that
are event triggered (e.g. a user uploading a photo which
triggers notifications to his/her followers). Developers
create functions and depend on the infrastructure to
allocate the proper resources to execute the function. If the
load on the function grows, the infrastructure will create
copies of the function and scale to meet demand.
2
compute resources until customers start using the
application.
Elastic Sc
Scalability:
alability: Elastic scalability is also simple with a
serverless architecture. If a function needs to scale, the
infrastructure will make copies of the function to handle
the load. An example of this could be a chatbot that
responds to weather requests. In a serverless architecture,
a chatbot function would handle the response by retrieving
the users location and responding back with the
Figur
Figuree 2: Microservices Architecture temperature. For a few requests this is not a problem, but
what happens if the chatbot service is flooded with
For a serverless architecture, the User service would be thousands of request a second. For this scenario, the
separated into more granular functions. In Figure 3, each chatbot function would automatically scale by instantiating
API endpoint corresponds to a specific function and file. thousands of copies of the function. Once the requests
When a create user request is initiated by the client, the have subsided, the environment would automatically
entire codebase of the User service does not have to run; terminate the idle instances and scale down, allowing costs
instead only create_user.js will execute. There is no need to to scale proportionally with user demand.
pre-provision containers, as standalone functions only
consume resources when needed, and users are only Rapid Development and Iteration: Serverless computing
charged on the actual runtime of their functions. is ideal for companies that need to quickly develop,
prototype, and iterate. Development is faster since there
arent any dependencies on IT Ops. Functions are typically
single threaded, which makes debugging and deploying
functions simpler. The build process is also broken down
into smaller and more manageable chunks. This increases
the number of changes that can be pushed through the
Continuous Delivery pipeline, resulting in rapid deployment
and more iterative feedback.
3
Serverless Computing Principles queues, and applications can respond quickly to events and
scale as needed.
Embrace T Thir
hird
d Party Services: Serverless computing
St
Stateless
ateless Single-Purpose F Functions:
unctions: For a serverless
vendors may not comprise all the technologies that
architecture, it is good practice to design functions around
developers are familiar with or need. Leveraging third party
the Single Responsibility Principle (SRP). A function that is
services and applications allow developers to pick the right
developed to perform a specific task is easier to test,
tools to help accomplish the task at hand. There are many
deploy, release, and is also more robust. Functions
services that developers can leverage from Auth0 for
designed with well defined interfaces are also more likely
authentication to Braintree or Stripe for payment
to be re-used. From a deployment unit point of view,
processing. It is much more useful for a developer to spend
serverless functions are stateless, which means local
time solving a problem unique to their domain, than it is to
resources and processes will not be retained after the
recreate functionality that has already been built by
function executes. This allows the platform to quickly scale
someone else.
to handle an increasing number of events or requests.
Mor
MoreeF Frront-End F
Functionality:
unctionality: In serverless
architectures, functions that terminate faster are less MongoDB Atlas and Serverless
expensive. Creating more functionality in the front-end
Computing
helps to reduce costs by minimizing the number or
complexity of function requests. This contrasts the typical
application models where all requests flow through the With MongoDB Atlas, users can leverage the rich
back-end layer before being routed to the database. The functionality of MongoDB expressive query language,
emergence of rich client-side application frameworks, such flexible schema, always-on availability, distributed scale-out
as AngularJS, make it possible to seamlessly execute from a serverless environment. MongoDB Atlas is a
complex functionality within the browser. Back-end logic is database as a service and provides all the features of
decoupled from the server and moved to the front-end, MongoDB without the heavy lifting of operational tasks.
allowing the front-end to communicate with more services. Developers no longer need to worry about provisioning,
This reduces the number of hops required to access a configuration, patching, upgrades, backups, and failure
resource and results in better performance and a richer recovery. Atlas offers elastic scalability, either by scaling up
user experience. on a range of instance sizes, or scaling out with automatic
sharding, all with no application downtime.
Design Event Driven Pipelines: Building event driven,
push based pipelines is powerful and allows you to scale Setting up Atlas is simple.
out architectures easily. An event driven pipeline is a chain
reaction of events that propagate down the pipeline
without any user input. For example, a user could upload a
video file which kicks off a function that takes the file and
video encodes it into multiple formats: 480p, 720p, 1080p.
The newly encoded videos are saved to a storage service,
which triggers another event. A function responds to the
event and creates metadata about the videos that is
pushed to a database. Metadata is saved to the database,
which triggers another function that creates an email
notification sent to the user confirming the video has been
encoded to the different formats.These actions all happen
asynchronously without any user input. With event driven Figur
Figuree 4: Provisioning MongoDB Atlas cluster
pipelines, there is no need to manage servers or event
4
Select the instance size that fits your application needs and entry to understand the codebase, resulting in higher
click CONFIRM & DEPLOY. software performance and developer productivity.
Figur
Figuree 5: MongoDB Atlas Cluster Monitoring
5
Atlas is designed with scalability as a core principle. When
your cluster hits a certain threshold, MongoDB Atlas will
send you an alert and with one click you can provision new
servers.
Flexible Sc
Schema:
hema: Because serverless architectures are
event driven, many use cases revolve around around the
Internet of Things (IoT) and mobile. MongoDB is ideal for
these use cases and more as its flexible document model
enables you to store and process data of any type: events,
geospatial, time series, text, binary, and anything else.
Adding new fields to the document structure is simple,
making it easy to handle changing data generated by event
driven applications. Developers spend less time modifying
schemas and more time innovating. Figur
Figuree 7: Server vs. Serverless Break Even Point
Cloud Pr Provider
ovider L Loc
ock-In:
k-In: Each cloud provider has their
Important Considerations Before own implementation of serverless computing; thus it is
Going Serverless likely that features will vary significantly from platform to
platform. This makes the risk of cloud provider lock-in high,
as porting functions between different providers is difficult
Though serverless computing offers many advantages, and expensive. Not only will you need to update your
there are several considerations to keep in mind before operational tools (deployment, monitoring), but you will
implementing a serverless project. most likely also need to update your code to be compatible
with the different interfaces. Users are more susceptible to
Underst
Understand
and YYour
our Br
Break
eak Even P Point:
oint: It is important to
changes in pricing, performance, and stability as there is
understand the break even point for your application. For
less flexibility to shift to another provider.
an application that only handles tens of requests an hour, a
serverless architecture is cost effective. On the other hand, High StStartup
artup Latency: For a function thats just been
for an application that handles thousands of requests per created, or hasnt been used recently, the startup latency
second it may be cheaper to provision more servers, rather will be high because the environment will have to spin up a
than pay for millions of processes a month. Figure 5 is new container before the function is executed. This can be
hypothetical and not based on real numbers, but illustrates problematic for certain applications that see intermittent
that beyond a specific number of requests it may not be traffic patterns or require low latencies (e.g. financial
economical to use a serverless architecture. trading applications).
6
Lac
Lack k of Resour
Resources
ces and Skillsets: Serverless computing
Resources
is a nascent field, which means hiring knowledgeable
developers or experts is difficult. Learning serverless
computing requires a steep learning curve and resources For more information, please visit mongodb.com or contact
are not easily accessible. There isnt a wealth of us at [email protected].
information on Stack Overflow or other forums. Books
Case Studies (mongodb.com/customers)
detailing best practices are also scarce, resulting in trial
Presentations (mongodb.com/presentations)
and error for many developers.
Free Online Training (university.mongodb.com)
Webinars and Events (mongodb.com/events)
Resources
New York Palo Alto Washington, D.C. London Dublin Barcelona Sydney Tel Aviv
US 866-237-8815 INTL +1-650-440-4474 [email protected]
2017 MongoDB, Inc. All rights reserved.