What is Serverless computing?

A way of running applications in which provisioning servers, managing their number and updating the OS are left to the cloud provider, so users need not think about them. The typical form is FaaS (Function as a Service): a function runs only when a request or event arrives, and charges depend on the number of executions, their duration and the memory used. Scaling with load is automatic, and almost nothing is charged when it is not used. On the other hand, there are constraints such as cold starts, where the first call after a period of inactivity is slow, and limits on execution time.

Japanese name: サーバーレス

Serverless computing appears in 1 practice question across 1 topic, including Cloud and Container Basics.

Field: Cloud and Container Basics

There are servers after all

"Serverless" does not mean there are no servers; it means users do not have to manage them. The provider prepares execution environments such as containers or lightweight virtual machines on demand and runs the functions in them. Whole applications are often assembled by combining functions with managed databases, storage, message queues and so on.

Cold starts

When a function is not called for a while, its execution environment is cleaned up, and the next call requires preparing an environment, starting the language runtime and initializing the function. This delay is a cold start, and depending on the language and the amount of libraries it can range from hundreds of milliseconds to several seconds. It is reduced by keeping initialization light or by using settings that keep a number of environments ready in advance.

Suitable workloads

It suits event-driven processing that finishes quickly, such as converting uploaded images, periodic aggregation and receiving webhooks, and workloads with large swings in load and long idle periods. For workloads under constant high load, always-on servers or containers can be cheaper. State is not kept inside functions but in databases or similar.

Try it: questions about Serverless computing

With serverless functions (FaaS), only the first call to a function that has not been called for a while sometimes responds hundreds of milliseconds to several seconds slower. Which of the following correctly explains this phenomenon?

  1. AThe result of the first call is cached, and from the second call on the function code is not executed and only the stored result is returned
  2. BIt takes time to prepare a new environment to run the function, start the language runtime and run initialization (a cold start)
  3. COn the first call the function code is sent to the user's device, compiled there and then executed
Show answer and explanation

Answer: B. It takes time to prepare a new environment to run the function, start the language runtime and run initialization (a cold start)

For serverless functions, the provider prepares execution environments (such as containers or lightweight virtual machines) as needed and cleans them up when they are not used for a while. The first call after an environment has been cleaned up requires preparing the environment, starting the language runtime and running the function's initialization, and the response is slower by that amount. Subsequent calls reuse the prepared environment and are faster (a warm start). Countermeasures include keeping initialization and the libraries loaded light and using settings that keep a certain number of environments ready in advance.

FAQ

Are serverless and containers opposites?

No. Many serverless platforms use containers or lightweight virtual machines internally, and some services can run a container image directly as a function. The difference lies in who manages the number of instances and the execution environment.

Does going serverless always reduce costs?

Not necessarily. Because you pay for what you use, it is cheaper for light, bursty workloads, but for workloads with a constant load above a certain level, always-on servers can be cheaper. The comparison should also include charges such as data transfer.

Serverless computing in the explanations

Questions that mention Serverless computing (1)

  1. With serverless functions (FaaS), only the first call to a function that has not been called for a while sometimes responds hundreds of milliseconds to several seconds slower. Which of the following correctly explains this phenomenon?

Books on Cloud and Container Basics Ad

As an Amazon Associate I earn from qualifying purchases.

Related terms

Container Autoscaling Availability zone Blue-green deployment Canary release Container image Docker Immutable infrastructure Infrastructure as code (IaC) Kubernetes

Back to the glossary