Serverless (Function-as-a-service) Flashcards
Problems
Some services can be coded in only a few lines of code.
Some services are called infrequently.
The load of some services can change very fast.
Are these services a good fit for something like Azure App
Service / Google App Engine? Why?
Having a machine / server running these services all the time is
an overkill.
Cloud functions
Cloud functions are small pieces of code, written in a high-level
language.
When is a cloud function invoked?
A cloud function is invoked when some event occurs – such as
loading an image into cloud storage, receiving a read from a
sensor, etc.
What is the serverless system responsible for?
The serverless system is responsible for the provisioning and
administration tasks: instance selection, scaling, deployment,
fault tolerance, monitoring, logging, security patches, and so
on.
Serverless vs Serverful
Decoupled computation and storage. The storage and
computation scale separately and are provisioned and priced
independently. In general, the storage is provided by a
separate cloud service and the computation is stateless.
Automatic resource allocation. Instead of requesting
resources, the user provides a piece of code and the cloud
automatically provisions resources to execute that code.
Paying in proportion to resources used instead of for
resources allocated. Billing is by some dimension associated
with the execution, such as execution time, rather than by a
dimension of the base cloud platform, such as size and number
of VMs allocated.
What are the key factors for making FAAS possible
Virtual machines and containers are the key to make FaaS
possible, making multi-tenant hardware sharing possible
For making the creation of the execution environments for
running function fast, several optimization are users:
* “warm pool” of VM instances that need only be assigned to a
tenant;
* “active pool” of instances that have been used to run a
function before and are maintained to serve future
invocations.
Types of Azure Functions Triggers
HTTPTrigger – function executed on an HTTP request.
TimerTrigger – execute cleanup or other batch tasks on a
predefined schedule.
CosmosDBTrigger - Process Azure Cosmos DB documents
when they are added or updated.
BlobTrigger - Process Azure Storage blobs when they are
added to containers.
EventHubTrigger - Respond to events delivered to an Azure
Event Hub, such as in application instrumentation, and
internet-of-things (IoT) scenarios.
Azure durable functions
Durable Functions is an extension of Azure Functions for
writing stateful functions.
Azure function can have stateful entities. The system manages
state, checkpoints, and restarts.
AWS Lambda
AWS Lambda lets you run code without provisioning or
managing servers. You pay only for the compute time you
consume - there is no charge when your code is not running.
Use cases for AWS Lambda
Realtime file processing – execute
Realtime stream processing
Extract, transform, load
Lambda@Edge
Lambda@Edge is a service that allows to run Lambda functions
in the Amazon points-of-presence (CDN).
As other FaaS services, clients pay only the compute time they
consume.
Inadequate storage for fine-grained operations
Difficult to support applications that have fine-grained state
sharing needs (due to stateless nature).
Limitation of current storage services.
* BLOB storage services are highly scalable and provide
inexpensive long-term object storage, but exhibit high
access costs and high access latencies.
* Cloud databases are expensive and can take a long time to
scale up.
Relying to caching services, such as Redis, is a good solution.
Poor performance standard communication patterns
Broadcast, aggregation, and shuffle are some of the most
common communication primitives in distributed systems.
* These operations are commonly employed by applications
such as machine learning training and big data analytics.
* With cloud functions the complexity of these tasks
increases, as the number of tasks also increases.