Serverless, explained.
Your app runs when someone uses it. The cloud starts copies as requests arrive, and you pay for the time they run.
- Requests
- Serverless capacity, follows requests
- Fixed servers, sized for the peak
- Paid for, sitting idle
Serverless vs a traditional deployment.
The servers still exist, but they become the cloud provider's job, and capacity comes per request instead of up front. Here is what changes for your team.
You choose server sizes, set them up and keep enough of them running.
The cloud provides computing power when a request arrives. There are no servers to size.
Your team updates the operating system and runtime on every server.
The cloud keeps the machines underneath patched. You update your own code.
You add servers ahead of busy periods, or tune autoscaling rules.
More copies of the app start as requests rise and stop as they fall.
Every server, every hour, busy or idle.
The requests served and the time your code runs. Databases and storage are billed as usual.
New code is copied onto running servers, often one at a time.
Each release is a new version. Traffic moves to it once it is ready, and the old one stays for rollback.
The app is down until the server is repaired or a standby takes over.
Copies run across several data centers in a region, so one failing machine does not take the app down.
Pages slow down or fail until more servers come online.
New copies start in seconds. A copy that starts cold answers its first request more slowly.
How a request is served.
Follow one visit from start to finish, including the start-up wait you may have heard about.
A request arrives
A visitor opens a page, or another app calls your API.
A copy picks it up
A copy of your app that is already running takes it. If none is free, the provider starts one.
Your code answers
It runs as it always has: reads the database, renders the page, sends the response.
Then it waits, or stops
The copy stays ready for the next request, and idle copies stop when traffic drops. SKE can keep some warm.
The trade-offs, and how SKE handles them.
Serverless has real limits. Each one has a well known answer, and SKE sets that answer up for you.
- Cold starts
When a new copy of the app starts, its first request waits while it loads.
SKE keeps copies warmSet how many copies stay ready, so visitors reach one that is already running.
- Time limits per request
A request can only run for so long, so a big import or report can be cut off.
Long work goes to queuesHeavy jobs run in the background on their own workers, and recurring tasks run on a schedule.
- No lasting local disk
Each copy of the app is temporary, so files written to its disk disappear.
State lives in managed servicesDatabases, caches and file storage are created for you in your cloud account, or you bring the ones you have.
When it fits, and when it does not.
Most web apps fit well. A few kinds of work need a small change first, and a few are better left on servers.
A good fit
- Web apps and APIs with traffic that rises and fallsCapacity follows the day, so quiet hours cost little.
- Apps with background jobs and scheduled tasksQueues and schedules run without a server waiting for work.
- Staging, QA and preview environmentsThey sit idle most of the day, and you pay for compute only while it runs.
- Teams and agencies running many appsNo fleet of servers to size, patch and watch for each one.
Think twice
- One request that runs for many minutesRequests have a time limit. Split the work into queued jobs instead.
- Apps that must keep files on local diskEach copy is temporary. Files belong in storage or a database.
- Steady, heavy traffic around the clockServers that are always busy can cost less than paying per request.