Building an Auto-Scaling Lambda based on Github's Workflow Job Queue
ClickHouse replaced CloudWatch-alarm-based EC2 Auto Scaling for its self-hosted GitHub Actions runners with a Lambda that reads the workflow job queue, built from GitHub webhook events stored in ClickHouse, and sets desired capacity directly. The Lambda compares current runners against in-progress and queued jobs, then scales up by roughly deficit/5 and down by reserve/2. The old rule (add a runner after 5 minutes above 97% busy) took hours to warm up groups of 50+ runners. The new approach launches jobs faster, saves compute when load drops, and keeps busy and active runner counts much more closely aligned.
Related posts
- Using ClickHouse to Monitor Job Queues in GitHub Actions
ClickHouse mediumAdept
GitHub Actions lacks built-in metrics for its workflow job queue, but an organization-level webhook emitting workflow_job events can feed an AWS Lambda that inserts each event into a ClickHouse MergeTree table. The post provides the table schema (LowCardinality columns, an Enum8 status, partitioning by month, ordering by id and updated_at) and example SQL queries. These use argMax over updated_at to recover each job's latest status, chart queued and waiting jobs per hour, compute queue time percentiles by time of day, and show the current queue size per self-hosted runner label.
- How GitHub uses GitHub Actions and Actions larger runners to build and test GitHub.com
GitHub Engineering mediumAdeptGitHub moved CI for GitHub.com to GitHub Actions on larger runners, peaking at about 4,500 concurrent 32-core runners, 15,000 jobs per hour and 150,000 cores. Custom VM images that pre-bundle tools and a cached build of the project source, refreshed several times a day through an API, cut workflow time from about 50 to 12 minutes. Reusable workflows keep CI configuration and runner selection central across repositories, and reusing results when Git tree IDs match skips 300-500 runs a day. Isolated runners reach private VPC services through an OIDC-token-validating remote access gateway, whose scaffolding is open-sourced.
- How we tripled max concurrent jobs to boost performance of GitHub Actions
GitHub Engineering mediumAdeptGitHub Actions on GitHub Enterprise Server went from 2,200 to 7,000 max concurrent jobs on 96-core machines between GHES 3.2 and 3.6 through three main fixes. A hot path for workflow secrets and callback URLs had silently never used its cache, which only showed up in profile traces. Orchestration state moved from a single growing blob column to a per-event table with incremental reads and writes, cutting orchestration CPU by about 50%. Postback load to the Rails checks service was reduced by deferring step updates until run completion and removing duplicate completion events, with a message queue planned to replace the multi-hop HTTP delivery.
- Monitor your CI performance using Sentry
Sentry mediumAdeptSentry's tracing model can represent GitHub Actions workflows as traces, with each job's steps as spans, so slow steps and run-to-run variance show up the same way they would for an API request. Applied to the Sentry .NET SDK's macOS build job, it showed the Build step taking about 44 of 83 minutes. Better caching across runs and parallelized tests cut the job to about 24 minutes, a 71% reduction, and custom dashboards tracking p50/p90 showed overall workflow runs about 64% faster. Setup takes a Sentry project, a private `.sentry` repo with a `sentry_config.ini` holding the DSN, and an experimental GitHub App that reads Actions metadata. Ingested jobs count against your span quota.
- Infrastructure Observability for Changing the Spend Curve
Slack Engineering mediumAdeptSlack bent the growth curve of its webapp CI spend, which had been rising about 10% month over month, by using observability (dashboards, metrics and tracing) to drive three changes. Adaptive capacity standardized instance types and oversubscribed executors per instance after profiling vCPU and executor-count combinations, cutting costs about 70% and error rates about 50% while targeting 50% busy executors at peak. Circuit breakers in the Checkpoint orchestrator defer or cancel CI work when downstream services such as Jenkins, Vitess, Flannel or Search degrade, which stops cascading failures. Tracing the Cypress test runtime exposed runtime variables tied to flakiness, which had been burning roughly 90k compute hours a week.