Brewless Brewless Docs

Running your application

Scaling

How to set the bounds your provider scales an environment between, and how to see how much of the time it was scaled to zero.

On this page

You set between how many replicas of the web container your provider may scale. The provider scales by itself within these bounds; Brewless is not involved in each decision.

brewless scale production --min=1 --max=10

The same bounds can be set in the console, on the Scale tab of the environment's Resources page, or in your brewless.yml under web.min and web.max, where a deploy applies them. Bounds the file sets are shown in the console as set there, and changing them in the console or with brewless scale is refused: change the file and deploy. The file can also give each container its memory, processor time, timeout and local disk; see brewless.yml.

Option What it sets
--min The fewest replicas. 0 lets the container sleep when idle
--max The most replicas your provider may start

Scaling to zero

With a minimum of 0 the container sleeps when nobody asks for it. The first request after that waits for the container to start.

Tip

Scale to zero on staging and development environments, and keep at least one replica on production if the first visitor should not wait.

For a burst of requests at a known moment, such as a ticket sale, raise the bounds before it; see Handling peaks.

Availability

With one web replica, a restart of that replica, or a host at Scaleway that fails, leaves your visitors without an answer for a moment until a new one runs. Two replicas or more (web.min: 2) take that moment away. A replica that keeps running is billed by Scaleway all the time, so Brewless never adds one by itself: for a production environment with fewer than two, brewless plan says so next to web.min, and that is all. Scaleway does not say whether the replicas of one container run in different zones.

Serverless usage

The page of an environment shows how much of a period its web container ran and how much of it was scaled to zero:

Figure What it means
Runtime The time at least one instance was running
Scaled to zero The time no instance was running
Scale-to-zero Scaled to zero as a share of the whole period
Cold starts How often the container went from no instance to at least one
Most replicas The most replicas that ran at the same time in any one hour of the period

The period is the last 30 days unless you choose 24 hours, 7 days, 90 days or 12 months. Above the figures one sentence answers the question outright: that it did not scale to zero once in this period, or how long it was at zero and how often it started from cold. The timeline under the figures has a bar per hour or per day; the filled part is the share of it the container ran, and the unfilled top is the time it was at zero. A bar with any time at zero in it keeps a notch of it however little that was, since five minutes in an hour is a sixtieth of a bar and would otherwise round away to nothing.

Under those bars, on the same time axis, a second row says how many replicas ran at the same time at most in that same hour or day. It is scaled to the web.max of the environment, with a rule drawn at that ceiling, so a bar that reaches the rule says the provider went no further; when the ceiling is not known, or the period went over it because it was lowered since, the row is scaled to the highest number in the period instead and the "i" beside the legend says so. For 90 days and 12 months a bar is a whole day, and then it is the highest of that whole day, however short the peak was: a minute at three replicas draws the same bar as a day at three.

The row makes two things visible that the one figure does not: whether a slow afternoon was Scaleway refusing to scale further or the container itself being slow, and the warm-up after a release, which shows up as a short peak and explains why that hour had so much traffic reaching the container.

These figures and both rows of the timeline are of the web container by default, measured by Scaleway itself. Worker above the panel shows the same figures for the worker container: how long it ran, how long it was scaled to zero, its cold starts and its replicas, counted from the hour Brewless started counting it. A cron or a message from a queue at the provider reaches a container directly rather than through the edge, so it wakes the worker without turning up in the addresses under what reaches the container. That is why the worker view also lists what wakes the worker, read from Scaleway when you open it: each cron by name and schedule, and each queue whose jobs start it, never the arguments of a cron. When the scheduler runs on a cron every minute, 1,440 wake-ups a day, the panel says so: that worker cannot sleep. Brewless falls back to that cron when it cannot tie the crons to the moments of your Laravel schedule, or when your jobs do not wait at Scaleway Queues. With scheduler: false and no queue to look in there is no cron at all, and the panel says nothing wakes the worker.

These figures are about the container. How long a serverless database was up, measured the same way from Scaleway's own figures once an hour, and how the storage of every database grew, is on the Databases page. How long a realtime server ran is counted the same way and shown on the environment's Realtime page: see What it ran this month.

Note

Scaled to zero is not downtime. Your provider starts an instance as soon as a request comes in.

A container that hardly ever scales to zero is woken by requests: Scaleway lets it sleep only after 15 minutes without one. Let the edge answer the pages that are the same for everybody; see Edge cache.

Monthly report

On the 1st of every month, at 09:05 Dutch time, every member who sees the applications gets a mail about the month before: per application, how much of it the web and the worker container of each environment were scaled to zero, and the same for each serverless database, from the same recorded hours as the figures above. A database that serves several environments is listed once, with their names. Members who do not see the databases get the report without them.

Only what may scale to zero is in it: a container with a minimum of 0 replicas (web.min, worker.min), and a serverless database with min_vcpu at 0. A container that keeps a replica running and a managed database never scale to zero and are left out, and so is anything without a recorded hour in the month. When nothing is left, no mail goes.

Something that was at zero less than half of the time it was counted, over at least a day, is marked Could sleep more, and the mail ends with tips for that kind, each with a link to the page that explains it: what keeps your container awake and what reaches the container for a web container, how the worker is called for a worker, and database costs for a database.

The report is on for every member. Switch Monthly scale-to-zero report off on your Account page, or follow the link at the bottom of the mail; see Mail from Brewless.

What reaches the container

Which requests wake the container is on the page of an environment behind bunny.net, under What reaches the container, and in a terminal with brewless wakes production. Brewless reads the request log of the environment's pull zone at bunny.net when you ask, and lists the addresses of the last 24 hours that the edge did not answer itself, most first, with how often and with the cache status bunny.net logged:

Cache status What it means
MISS Not at the edge yet, so fetched from the container
EXPIRED At the edge, but its time there was up
BYPASS Never kept, such as a page with a cookie or one that sets Cache-Control: private
REVALIDATED, UPDATING Checked with the container again, or fetched again in the background
no cache A request the edge never keeps, such as a POST

On the page, next to the addresses:

  • Wake-ups: the moments the container started, newest first, read from its own log at Scaleway (the line FrankenPHP writes when it starts). Each is put down to the first request the edge passed on around it (bunny.net logs a request when it has answered it, so the one that started the container stands a few seconds after the start), with the time, the address, the client, its HTTP status and how long it had been quiet. A start around a release is the release's. A start with no request through the edge just before it came from somewhere else: a request straight to the container's own address, or Scaleway itself, and the page says so. A MISS in bunny.net's log is not a wake-up by itself: it is what one edge server did, and Origin Shield answers most of those without your container — bunny.net's log has no line for the shield's own answer. Only when the container's log cannot be read does the page fall back to a guess, the first request after 15 minutes without one, and it says it guessed. A container with web.min of 1 or more never sleeps, and the page says so instead.
  • Requests per hour: a bar for every whole hour the 24 hours touch, darker in an hour in which the container woke.
  • Per address: when it came first and last, its HTTP statuses, the clients that asked most, the hostnames it was asked on, and the sites it was linked from.
  • Who asked: how many of the requests came from known bots (with their group), scanners, unknown bots and humans, each marked as counted or estimated. What wake-ups only bots and scanners caused costs over the days Brewless counted is under it: see avoidable wake-ups.

A client is shown by its name, never by its user agent: a crawler by the name with "bot", "crawler" or "spider" in it (Googlebot, GPTBot), the agents of AI assistants and a few others by their own name (ChatGPT-User), a browser as Chrome, Safari, Firefox, Edge or Opera, the edge warm-up as Brewless edge warm-up, and anything else by the first name in its user agent (curl). Of a referrer only its hostname is shown, and a link from the address's own hostname is left out.

An address that comes back with a different query string is a new address at the edge each time: /?utm_source=newsletter and /?utm_source=mastodon both go to the container. The list shows only the names of a query string (/?utm_source=…), never its values. Built files come from the storage zone instead; they are counted apart and do not wake the container.

What the edge answers from a rule of its own is counted apart too, and the page says how many there were. An address asked over plain HTTP is sent on to https, a scanner address is refused, as is a query string with rest_route in it or Joomla's option=com_… on /index.php, and so is a path the file names in edge.refuse or edge.require_xhr, all at the edge: the container never sees any of them. bunny.net logs them without a cache status, the same way it logs a POST, so before Brewless told them apart they read as requests that had reached the container and could make a sleeping environment look wide awake. A search the edge script answered from your search index, and a redirect it answered from your redirect table, are counted as the edge's too: bunny.net logs both as a MISS.

A file asked for with a version (?v=) is counted as your storage zone's when the release that is live put those files there, and as your container's when it did not. bunny.net's log names no answerer — a ?v= address looks the same whichever origin served it, and a rule standing on the zone is no proof that it fired — so the deciding word is what the deploy wrote down: its versioned files step says whether the zone holds the files of exactly this release. Does it not, then those requests are the container's and the page says how many they were, so a figure that reads higher for that reason can be told from a site that got busier. A file of public/ asked without a version is counted as the zone's when it is one of the paths that step wrote down for the rules without a version.

A page the edge took from the storage zone with edge.keep_pages is counted apart as well. bunny.net logs such a page as a MISS, because the script that fetches it hangs on the moment the edge has just decided the page is not in its cache — so without this it read as a request the container had answered, and on a site of a few hundred pages that is most of the list. Brewless tells them apart by reading which pages are in the zone: a MISS on a page that is there never reached the container.

Note

The log says what the edge did with a request, not who answered it, so the line is drawn as narrowly as the log allows. Only a MISS counts as a page from the zone. A POST is logged without a cache status and a request that carries a cookie as a BYPASS, and the edge passes both of those on to the container — /contact is a page in the zone and a form that is posted to, and its POSTs are real wake-ups. A page store with more folders than Brewless reads at once says so on the page, and the pages it did not read stay counted as the container's.

bunny.net keeps the log for three days, with the visitor's address anonymised; Brewless never reads that address, and keeps none of the log and shows it for a few minutes from a cache. Of each whole day it keeps only how many requests of each kind reached the container, for avoidable wake-ups. A zone with more than 50,000 such requests in a day is counted from its newest, and the page says so. The same line appears when the reading runs out of time or bunny.net stops answering partway through a very busy day: what was read is kept and shown, rather than nothing at all. Reading the log never asks anything of the container.

How it is counted

Once an hour Brewless reads from Scaleway, per minute, whether the container had an instance, and keeps the totals of each hour. Several instances at the same time count as one minute of runtime.

Brewless never sends a request to your application to measure it. A health check would keep the container awake; counting from the provider's own figures does not.

Scaleway keeps its figures for about a month. The hourly totals stay at Brewless, so longer periods can be shown. Counting starts at the first hour the container was seen running, and a period that reaches further back shows what was recorded since.

Live figures

The page of an environment also shows requests, response time and the number of replicas right now. These are read live from your providers; Brewless does not store them.