Sub topic 7
Choosing queue settings
This chapter assumes you know how a merge queue builds merge groups and that your required checks already run on the merge_group event. Here you will choose the values that control how the queue behaves. Every setting trades speed, CI cost, and how much blame a failure can place on one pull request.
The settings at a glance
GitHub exposes the same settings in a branch protection rule, in a repository ruleset, and in the rulesets REST API. The names differ between the web interface and the API.
| Setting in the web interface | API parameter | Default | What it controls |
|---|---|---|---|
| Merge method | `merge_method` | Merge commit | How each pull request lands on the base branch: `MERGE`, `SQUASH`, or `REBASE` |
| Build concurrency | `max_entries_to_build` | 5 | How many merge group branches can run checks at the same time |
| Maximum group size | `max_entries_to_merge` | 5 | The most pull requests that can be merged in one operation |
| Minimum group size | `min_entries_to_merge` | 1 | The fewest pull requests the queue will merge together |
| Wait time to meet minimum | `min_entries_to_merge_wait_minutes` | 5 | How long the queue waits for the minimum before merging a smaller group |
| Status check timeout | `check_response_timeout_minutes` | 60 | How long the queue waits for required checks before treating the group as failed |
| Only merge non-failing pull requests | `grouping_strategy` set to `ALLGREEN` | `ALLGREEN` | Whether every commit in a group must pass, or only the head commit (`HEADGREEN`) |
These defaults are the ones GitHub showed when this chapter was written. Check your own settings page before you rely on them.
How the settings fit together
Pull requests enter the queue in order. The queue builds temporary merge group branches that stack each pull request on top of the ones ahead of it. Build concurrency limits how many of those branches run checks at once. Group size limits how many pull requests merge in a single operation.
Two points follow from this picture:
- Concurrency is about running checks early. Branch 2 already contains pull request 1, so it can start before pull request 1 finishes. If pull request 1 later fails, branch 2 is invalid and the queue must rebuild it.
- Group size is about running fewer checks. One run can cover several pull requests, but a failure in that run is harder to assign to one of them.
Merge method
Pick the method that matches your history policy, not the one that seems fastest. The queue applies your choice to every pull request.
- Squash gives one commit per pull request. It keeps
mainlinear and makes reverts simple. You lose the individual commits from the branch. - Merge commit keeps the branch history and adds a merge commit. Reading
mainis noisier, but you keep fine-grained history. - Rebase replays the branch commits onto
mainwithout a merge commit. History stays linear, but the replayed commits get new hashes.
Whatever you choose, the commit the queue tests is the one that lands. Teams that switch methods often do so for history reasons, not for queue performance.
Build concurrency
Raise concurrency when your CI is slow and your merge rate is high. With a 20-minute pipeline and concurrency 1, the queue can merge at most three pull requests an hour. With concurrency 5, up to five pipelines overlap.
The cost is wasted work when something fails. If pull request 2 fails, every branch built on top of it (3, 4, and 5) is discarded and rebuilt without it. The higher the failure rate and the concurrency, the more compute you throw away.
A practical rule: set concurrency near the number of pull requests that arrive during one CI run. If about three pull requests arrive per 20-minute run, a value of 3 or 4 is enough. Also check your runner capacity. If your CI cannot start five jobs at once, extra concurrency only adds queued jobs.
Group size and wait time
Maximum group size lets one CI run validate several pull requests together. This is the main cost lever. A group of five needs one pipeline where five separate branches would need five.
Minimum group size and wait time work as a pair:
- With a minimum of 1, the queue never waits. Each pull request starts as soon as a slot is free.
- With a minimum of 3 and a wait of 5 minutes, the queue holds back until three pull requests are ready. After 5 minutes, it goes ahead with whatever it has.
Raising the minimum makes batches fuller and cheaper but adds up to the wait time to the latency of the first pull request in each batch.
Grouping strategy
The grouping strategy decides which checks must pass before a group merges.
ALLGREEN(the default, "Only merge non-failing pull requests") requires the merge commit built for every pull request in the group to pass its required checks. A failure identifies the offending pull request.HEADGREEN("Always merge") requires only the head commit, which contains every pull request in the group, to pass. It does not wait for the earlier commits in the group, so checks on them can still be running or failing when the group merges. That saves time but can hide which pull request caused a problem.
Use ALLGREEN unless your checks are slow and you trust the final combined result. The next chapters cover how failures play out under each strategy.
Status check timeout
The timeout is how long the queue waits for the required checks of a merge group to report. If they do not finish in that time, the queue treats the group as failed and removes the pull request.
Set it above the slowest healthy run, including the time a job waits for a runner. A good starting point is your 95th percentile pipeline time plus a margin. A value that is too low removes good pull requests during busy hours. A value that is too high leaves a hung job blocking everything behind it, because later groups cannot merge until it resolves.
The timeout also catches a missing trigger. If a required workflow does not run on merge_group, no status ever arrives, and the group fails only when the timeout expires. A short timeout makes that mistake easier to notice.
Estimating cost before you commit
A quick calculation shows how group size affects CI use. This script gives a best case, assuming no failures and no rebuilds. Real usage will be higher.
import math
def ci_minutes_per_day(prs_per_day, pipeline_minutes, max_group_size):
"""Best-case CI minutes per day: one pipeline run per merge group."""
runs = math.ceil(prs_per_day / max_group_size)
return runs * pipeline_minutes
for group in (1, 3, 5):
minutes = ci_minutes_per_day(prs_per_day=40, pipeline_minutes=25, max_group_size=group)
print(f"max group size {group}: about {minutes} CI minutes per day")With 40 pull requests a day and a 25-minute pipeline, this prints 1000, 350, and 200 minutes per day. Treat the gap between group sizes as the upper bound on savings. Failures and partial groups reduce it.
Starting profiles
These starting points suit different teams. Adjust them after you measure.
| Team situation | Merge method | Concurrency | Max group | Min group and wait | Strategy |
|---|---|---|---|---|---|
| Small team, fast CI | Squash | 1 to 2 | 1 to 2 | 1, 5 minutes | `ALLGREEN` |
| Busy monorepo, slow CI | Squash | 5 | 5 | 1, 5 minutes | `ALLGREEN` |
| Expensive CI, steady traffic | Squash | 3 | 8 | 3, 10 minutes | `ALLGREEN` |
Change one setting at a time. After each change, watch queue wait time and CI minutes for a week before you change another.
Exercise
Your queue uses build concurrency 5 and max group size 5. Pull requests fail required checks about one time in four, and CI minutes are higher than expected. Which setting would you lower first, and why?
Show answer
Lower build concurrency. With a 25 percent failure rate, each failure discards every branch built on top of it, so high concurrency wastes the most compute. Lowering concurrency to 2 or 3 reduces discarded builds. Keep the group size, since larger groups reduce the number of runs, and only reduce it if failures in big groups are hard to trace.
Exercise
A required check takes 30 minutes on a normal day, but jobs sometimes wait 20 minutes for a runner. The status check timeout is 40 minutes. What problem can this cause, and what would you set instead?
Show answer
A run that waits 20 minutes for a runner and then takes 30 minutes needs 50 minutes, which exceeds the 40-minute timeout. The queue removes a healthy pull request. Set the timeout above the worst healthy case, for example 60 minutes, or fix the runner shortage.