# Build minutes

Builds use **build minutes**. Your plan includes some every month. This page explains how minutes are counted.

## What your plan includes

Each Workload and Web App plan includes a number of build minutes per month. The number is on the plan, so it is not repeated here.

- The minutes belong to the **service**, not the whole organization. They are not shared between services.
- They are counted by calendar month and start again on the 1st. Unused minutes do not carry over.
- If the service starts part of the way through a month, the first month's minutes are prorated by the days left.

The console shows what you have used. In the service, the **Builds** tab has a ring with the minutes used this month. **Settings > Builds** has a month meter for the organization and a table of minutes per service, grouped by project.

## How a minute is counted

- The clock starts when the builder starts running your build and stops when the build ends.
- The time is rounded **up** to a whole minute, and a build counts at least 1 minute.
- **Time in the queue is never counted.** Only the time the build is running.
- Cloning, preparing, building and pushing the image all count.
- If you cancel a build, the minutes it already used still count.

## Builder sizes

A minute here means a minute of the **small** builder. A bigger builder uses more of them for each minute that it runs:

| Size | Processors | Memory | Counts as |
|---|---|---|---|
| Small (the default) | 2 | 8 GiB | 1 minute per minute |
| Medium | 4 | 16 GiB | 2 minutes per minute |
| Large | 8 | 32 GiB | 4 minutes per minute |

Example: a build that runs for 6 minutes on a medium builder uses 12 build minutes. If your plan includes 300 minutes, that is 300 small minutes, 150 medium ones or 75 large ones.

Zaroz never changes the size by itself. A build runs on the size you chose. To choose it, set `build.size` in your [`zaroz.toml`](/git-builds/zaroz-toml). For one build only, choose **Rebuild on medium** on a failed build. The page of each build shows its size and the minutes it used.

Larger builders may not be available to every organization. If a size is not available, the build says so, with [`builder_size_above_pool_max`](/git-builds/troubleshooting#builder_size_above_pool_max) or [`builder_size_exceeds_pool_slots`](/git-builds/troubleshooting#builder_size_exceeds_pool_slots).

## Which failures use minutes

| What happened | Minutes |
|---|---|
| The build succeeded | Used |
| The build failed because of your code or settings, such as [`build_step_failed`](/git-builds/troubleshooting#build_step_failed), [`out_of_memory`](/git-builds/troubleshooting#out_of_memory), [`timeout`](/git-builds/troubleshooting#timeout) or [`config_invalid`](/git-builds/troubleshooting#config_invalid) | Used, for the time it ran |
| The failure was ours: [`builder_unavailable`](/git-builds/troubleshooting#builder_unavailable) or [`push_failed`](/git-builds/troubleshooting#push_failed) | Never charged |
| Zaroz refused to start the build: [`included_minutes_exhausted`](/git-builds/troubleshooting#included_minutes_exhausted), [`extra_minutes_limit`](/git-builds/troubleshooting#extra_minutes_limit), [`cost_not_confirmed`](/git-builds/troubleshooting#cost_not_confirmed), [`spend_cap`](/git-builds/troubleshooting#spend_cap), [`minutes_need_funds`](/git-builds/troubleshooting#minutes_need_funds) or [`builder_storage_full`](/git-builds/troubleshooting#builder_storage_full) | None, nothing ran |
| A build ran past the included minutes while extra minutes were off | The excess is not charged |
| The build worked but the deploy failed: [`pre_deploy_failed`](/git-builds/troubleshooting#pre_deploy_failed) or [`health_check_failed`](/git-builds/troubleshooting#health_check_failed) | The build's minutes were used, the deploy adds none |

When a failure is ours, Zaroz tries the build once more by itself.

## Extra minutes

**Extra minutes are off by default.** Nothing is charged for builds unless an Owner or Admin of your organization turns them on.

- **Off.** A build may start while the service still has included minutes. If it runs past them it finishes anyway, and the excess is not charged. When no included minutes are left, builds are refused with [`included_minutes_exhausted`](/git-builds/troubleshooting#included_minutes_exhausted) until the 1st of next month.
- **On.** Builds can go past the included minutes. Each extra minute of a small builder costs the rate of your plan, 0.005 EUR on the app plans, and a medium or large builder uses 2 or 4 of them per minute. The most you can pay in a month is the **monthly limit** you set. If a build could take you past that limit, it is refused with [`extra_minutes_limit`](/git-builds/troubleshooting#extra_minutes_limit).

To turn them on, open **Settings > Builds**, switch on extra minutes and choose a monthly limit: 4, 10 or 25 EUR, or another amount from 1 to 500 EUR. The page shows the rate and how many minutes the limit buys on each builder size. Zaroz records who turned them on, when, and with what limit. You can change the limit or turn them off at any time. A build that already started keeps the setting it started with.

Before you start a build by hand that may go past the included minutes, the console shows **the most it can cost** and asks you to confirm it. You only pay for the minutes it really uses. If the most it could cost goes up after you confirmed, the build does not start and you are told ([`cost_not_confirmed`](/git-builds/troubleshooting#cost_not_confirmed)). A build that nobody is waiting for, such as one started by a push, is never started if it does not fit: it is refused, and the organization is notified.

## The spend cap

The spend cap is a hard stop, on top of the extra minutes limit. Before a build starts, Zaroz works out the most it could cost: the build's time limit, times the size, beyond the minutes your plan still includes. The build starts only if that fits under your cap for the month. If it does not, the build is refused with [`spend_cap`](/git-builds/troubleshooting#spend_cap) before it runs, so your spending never passes the cap and no running build is stopped.

To make a build fit, raise the cap, pick a smaller builder, or lower the time limit with `build.timeout`.

Organizations without a credit limit pay from their wallet. For them, the wallet has to cover that same most-it-could-cost. If it does not, the build is refused with [`minutes_need_funds`](/git-builds/troubleshooting#minutes_need_funds).

## Limits that depend on your organization

To keep the service safe, organizations without a credit limit start with tighter limits: one build at a time, a shorter time limit and builders up to medium. Contact support if you need more.
