Serverless Laravel. No servers to manage.
Serverless means there is no machine of yours to patch, resize or watch. Your Laravel app runs as containers at Scaleway that start when a request arrives and stop when it is quiet, and you pay for the time they ran.
A server has a size. Serverless does not.
A server is one machine, on all the time, at one size you picked in advance. Too small and it falls over at the peak; too large and you pay all night for capacity nobody uses. Serverless replaces that one choice with a range: Scaleway starts copies of your app as traffic arrives and stops them as it drops.
No machine of yours
There is no operating system to patch, no disk to fill up and no instance to resize. Scaleway runs the machines and keeps them current.
Copies on demand
Each copy of your app is a container. One handles a number of requests at a time; when more arrive than the running copies can take, another starts, up to the ceiling you set.
Down to nothing
Set the minimum to zero and a quiet app keeps no copy running at all. You pay for the time your containers were awake, not for a machine standing by.
Pages from the edge
A page that is the same for everybody is answered by bunny.net, so a crawler reading your public pages never reaches your app and never wakes it.
Scaling to zero, and waking up again.
A container sleeps after a stretch of quiet. The first request after that has to wait for one to start, which is the one real cost of scaling to zero. What matters is how often that happens and how long it takes.
- A container goes to sleep after about fifteen quiet minutes. Anything that reaches your app in the meantime keeps it awake, which is why a crawler, an uptime check or a session cookie on a public page can mean it never sleeps at all.
- A cold start is the time to pull your image, boot PHP and run your app’s first request. A smaller image and a warm framework cache make it shorter; an app that opens a database connection and reads config from disk on boot makes it longer.
- Set a minimum of one copy for an environment where the first visitor must never wait. You then pay for that one copy around the clock, and the rest still scales with traffic.
- The edge is what keeps most apps asleep. Every public page bunny.net can answer is a request your container never sees, so the quiet stretches are long enough to actually reach the sleep threshold.
- A queue worker and the scheduler are separate from the web containers. They wake when there is a job or a task due, run it, and go back to sleep, so a quiet app costs nothing between them.
A health check every minute would keep a container awake forever, which is the opposite of what you are paying for. Brewless reads what your app is doing from Scaleway’s own figures instead, so measuring it never costs you a wake-up.
A server next to serverless.
The same Laravel app, hosted the two ways, on the points where they actually differ.
| One server | Brewless on Scaleway | |
|---|---|---|
| Capacity | One size, picked in advance and changed by hand. | A range you set. Copies start and stop with the traffic. |
| A quiet night | The machine runs and bills at full price. | No copies, or the minimum you chose. |
| A sudden peak | Requests queue or fail once the machine is full. | More copies start, up to your ceiling. |
| Patching | Yours: kernel, PHP, web server, certificates. | Scaleway’s. You pick a PHP version; the rest is theirs. |
| The local disk | Stays between requests. Easy to lean on by accident. | Gone when the container stops, and not shared between copies. |
| A long-running worker | Supervisor keeps queue:work alive. | No process stays up; the queue calls a worker container per job. |
| First request after quiet | Immediate, because the machine never slept. | Waits for a cold start, unless you keep a minimum running. |
What changes in your Laravel app.
Most of a Laravel app does not care that it is serverless. Four things do, and all four are things that assume something survives between requests.
Nothing on the local disk
The disk does not outlive the container and is not shared between copies. Uploads belong in a bucket, which Brewless sets up and points Laravel’s s3 disk at.
Sessions and cache outside the container
Keep them in the database or a cache, never in files. Two visitors can be served by two different copies, and neither copy keeps anything for the next request.
No worker mode, no Octane
Brewless runs FrankenPHP in classic mode and refuses a build that declares a worker or starts Octane. State that outlives a request is a risk, and on containers that stop anyway there is nothing to gain.
Queues and the schedule are called
queue:work and schedule:work never end, so they cannot run here. The queue calls a worker container when a job is put on it, and the schedule, read from your app on deploy, calls one when a task is due.
Where you set it.
Scaling is a few lines in brewless.yml, in your repository, next to the rest of the environment. A change reaches the containers with the next deploy.
environments:
production:
web:
min: 1
max: 20
memory: 1024
worker:
max: 10
timeout: 300
Questions about serverless
- What does serverless mean for a Laravel app?
- It means no machine of your own. Your app runs as containers that Scaleway starts when a request arrives and stops when it is quiet, so there is nothing to patch or resize, and nothing billing you while the app is idle. Your Laravel code stays the same, except where it assumed something survives between requests.
- How long does a cold start take?
- It depends on your image and what your app does on boot, so there is no one figure worth quoting. What you can control is the size of the image, whether config and routes are cached, and how much your app does before its first response. If the wait matters for an environment, set the minimum to one copy and it never happens there.
- Does my app scale to zero automatically?
- Only if you set the minimum to zero, and only if nothing keeps reaching it. A container sleeps after about fifteen quiet minutes, so a crawler, an uptime monitor or a public page that starts a session can keep it awake all day. The edge cache is what makes the quiet stretches long enough.
- Can I run php artisan queue:work on Brewless?
- Not as a process that stays up. It is refused as a release command and as a one-off command, because it never ends. The worker container is called instead, either by the queue the moment a job is put on it or by a trigger every minute when your jobs are in the database.
- How many requests does one copy handle?
- A container handles several at once, and how many depends on the memory you give it and how long your requests take. You set the ceiling on copies in brewless.yml; Scaleway starts more as the running ones fill up and stops them again as traffic drops.
- Is serverless cheaper than a server?
- It depends on your traffic. Steady traffic around the clock suits a server, because a machine you keep full is cheap per request. Traffic with peaks and quiet nights suits serverless, because you stop paying during the quiet. An app that is idle most of the time is where the difference is largest.
Read more
- Laravel cold starts, and how to measure them
- Why your Laravel container never scales to zero
- Laravel queues without a long-running worker
- Which PHP versions Brewless runs, and why FrankenPHP
- Scaling and sizes in the documentation
The rest of Brewless
- Europe Which companies hold your app and your data, and where the exceptions are.
- Ownership What is yours, what is ours, and what keeps running if you stop paying us.
- What you get Everything a deploy sets up for a Laravel app, and the line in brewless.yml that asks for it.
- Pricing One plan fee from us, and your own provider bills at their list prices.
Want to try it on your own app?
Register with your work email and deploy your first Laravel app to your own Scaleway account today.
One application free, production included. No credit card; you start paying when you want your own domain or more.