Serverless computing is a cloud computing model that enables you to deploy code, databases, queues, etc. without having to manage the underlying infrastructure. To user serverless services, you don't need to do any capacity planning or autoscaling as the cloud provider will automatically scale up and down your resources as traffic fluctuates. Serverless services also typically have a "pay-per-use" pricing model, where as a developer, you only pay for the exact resources that were used by your application.
Serverless practitioners also often add "scales down to zero" as a requirement for serverless services. This means the service must not have a minimum capacity deployed: if the application has no traffic, you don't pay for anything.
In practical terms, this means that you can write a piece of code, upload it to a service like AWS Lambda or Azure Functions, and have it run in response to events HTTP requests. You don't need to provision servers or manage scaling; the cloud provider takes care of all of that for you.
Here's a simple example of a serverless function in JavaScript that responds to an HTTP request using AWS Lambda:
exports.handler = async (event) => {
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};