In serverless computing, short functions are deployed to a cloud service provider and executed on demand.
Serverless does not mean there is no physical server. Instead, the cloud provider is responsible for managing the servers required to run the functions.
Serverless is an important technology because it embodies the cloud computing mindset of not owning servers, perhaps more than any other cloud provider offering.
How serverless works
To use serverless, you first write a function in your preferred programming language (AWS supports Node.js, Python, Ruby, Java, Go or .NET Core).
You deploy this code to the cloud provider using a public API or the cloud’s command-line tools. Alternatively, you might copy-and-paste the code into the cloud provider’s management console.
The cloud providers has many servers, booted up, and waiting to handle incoming requests. When an incoming request arrives (this could be a HTTP request or an internal event generated by another service), then a server will download your deployed code and execute the function.
That same server will keep your deployed code in memory for several minutes or up to an hour, to handle any additional requests without needing to reload your code.
If there is a sudden surge of requests, then the cloud provider will load the code onto additional servers. Serverless can scale your code from one user to potentially millions of requests handled by thousands of servers nearly instantly.
Serverless offerings
All of the major cloud providers have a serverless offering:
Pricing should be a careful consideration with serverless. Serverless is ideal for websites with low usage but occasional bursts of high-demand. However, the cost per second is quite high. Predictable workloads with constant high-demand may be more affordable in traditional server configurations.