Skip to main content
🤖 Running agents for a team, not just yourself?Get an independent review of identity, secrets, failover, observability and governance.Assess your agent platform
Website editorial cover
DevOps

Less Waste, More Reliability: A CI/CD Optimization Case Study

A real-world CI/CD investigation into redundant builds, shared quotas, Astro memory profiling and backup resilience without a larger cloud budget.

Luca Berton

· The Production AI Expert

Published ·6 min read

A green production deployment is not proof of a healthy delivery system. A website can remain online while its recovery pipeline quietly stops working. That distinction became the central lesson of a recent investigation into CI/CD usage across a portfolio of web applications.

The goal was not to buy larger machines or move every workload to another provider. It was to reduce unnecessary work, protect essential operations and establish evidence for the next infrastructure decision. The investigation covered GitHub Actions, Vercel and static-site builds with Astro. Project names, domains, repository identifiers, exact incident dates and sensitive recovery details are intentionally omitted. Operational figures are rounded where appropriate.

CI/CD optimization field notes: reduce waste, measure build memory and protect recovery capacity

1. Find the waste before buying capacity

I started by inventorying workflow runs, conclusions, triggers and deployment targets, rather than treating every failed run as a billable build. In one representative workload, roughly 500 CI runs were recorded over a 30-day period, with more than 60% ending in failure. Around 45% of the most recent deployment sample consisted of previews.

Those counts are signals, not a cost calculation. A job rejected before runner allocation may consume no execution minutes, while a single long-running browser test can use more compute than many short jobs. The correct next step is to connect run counts to billable duration, runner type, cache behavior, storage and actual hosting usage.

The more important finding was a shared-resource dependency: routine automation and recovery operations competed for the same CI capacity. Backup runs had failed repeatedly. A recent attempt ended before any job steps ran, which was consistent with an admission or quota problem, but the missing logs prevented a definitive root-cause diagnosis for that specific attempt.

2. Reduce work without weakening release gates

The changes targeted work with little incremental value rather than removing tests indiscriminately.

AreaOptimizationGuardrail
Preview deploymentsMake automatic previews opt-in for selected branchesKeep normal production deployments
Documentation changesSkip expensive site compilation where appropriateRetain source checks and build for code or configuration changes
Scheduled social checksConsolidate four daily checks into oneRetain manual execution and pre-release checks
Browser testingAvoid redundant broad suites on every changePreserve required coverage on the production path
Static buildsReuse a single build artifact across tests and deploymentDo not deploy an unvalidated artifact

Reducing a four-times-daily schedule to one execution per day cuts that workflow’s scheduled run count by 75%. It does not imply a 75% reduction in the account’s total bill. Some checks can be consolidated safely, while others must remain independent because they protect distinct failure modes.

One additional lesson: a configuration change that disables previews can interact with required deployment status checks. Review branch protection before rolling out an opt-in policy. A skipped or missing check must not accidentally block ordinary pull requests or permit untested releases.

3. Measure build memory, not just the Node.js heap

A large Astro site had historically used a generous Node.js heap on a CI runner and deployed prebuilt output to its hosting provider. Image transformations were a suspected source of memory pressure. Rather than immediately change the build platform, I ran two controlled experiments using a smaller heap and reduced allocator and thread-pool settings.

ExperimentWarm asset cacheCold asset cache
Node.js heap limit4.5 GiB4.5 GiB
Build durationAbout 1m 45sAbout 2m 37s
Peak RSS reported by GNU timeAbout 3.2 GiBAbout 3.0 GiB
Sampled aggregate process-tree RSSNot measuredAbout 3.1 GiB
Build and browser testsPassedPassed

For comparison, the original heap limit was 12 GiB. Reducing that limit to 4.5 GiB is a 62.5% reduction in the configured heap ceiling, not a measured 62.5% reduction in real memory use. The cold run explicitly skipped restoration of the Astro asset cache and produced no reused image-cache entries.

How to reproduce the experiment

The following is a generic Linux example for a compatible pnpm-based Astro project. Run it in a disposable checkout, not against an active production build.

pnpm install --frozen-lockfile
rm -rf node_modules/.astro

export NODE_OPTIONS=--max-old-space-size=4608
export UV_THREADPOOL_SIZE=2
export MALLOC_ARENA_MAX=2

/usr/bin/time -v pnpm build

The actual experiment additionally sampled the resident memory of the build process and its descendants every half-second. This matters because Node.js heap usage alone does not account for native image libraries, subprocesses or allocator overhead.

GNU time’s maximum RSS is not a measurement of total simultaneous process memory. Summed RSS can double-count shared pages, and periodic sampling can miss short-lived spikes. Where available, a dedicated cgroup or container memory peak provides another useful measurement.

These results support testing a standard-memory build environment. They do not prove that an entire installation, build and packaging sequence will fit on a particular hosting machine. The production deployment architecture was not changed on the strength of this experiment alone.

4. Treat recovery capacity as a reliability requirement

The most consequential observation was not the number of builds. It was the absence of a recent confirmed successful backup for an extended period. A healthy database service is not evidence of recoverability.

The investigation identified the last recorded successful upload and added diagnostics for database connectivity, permissions, archive structure and private storage access. At the time of writing, the presence and restorability of the historical artifact had not been independently verified.

A recovery workflow should distinguish four separate states:

  1. Captured: a database dump was created successfully.
  2. Stored: the archive and its manifest were uploaded to private storage.
  3. Verified: the stored bytes match the expected size and cryptographic checksum.
  4. Restored: the data was successfully loaded and checked in an isolated environment.

A checksum can detect corruption; it cannot establish that the dump contains every required schema, role, external object or application dependency. An archive listing is useful, but an actual restore test is the stronger proof.

Retention deserves the same scrutiny. An age-based deletion rule should never remove the last known usable recovery point simply because a new job reports success. Preserve known-good copies, verify replacements and make deletion fail closed when inventory or retention configuration is uncertain. Test deletion policy with synthetic objects before enabling it against live storage.

These are recovery requirements, not claims that recovery has already succeeded. No credentials, database contents, object paths or live recovery identifiers are published here.

5. Measure outcomes after the changes

FinOps is a feedback loop. To compare the baseline and the optimized system, I would track:

  • Billable CI minutes by repository, workflow and runner type.
  • Failure rate, separating runner-admission failures from failures during execution.
  • Production and preview deployments, build duration and cache-hit rates.
  • Backup age, verified recovery points and the results of restore exercises.
  • Actual platform charges, normalized for changes in publishing frequency and workload.

The workflow reductions and memory experiments are observable results. Account-wide financial savings, complete recovery readiness and a hosting migration remain unverified. No additional paid capacity was activated during this investigation.

The takeaway

The cheapest build is often the one you do not need to run. But the most valuable CI job may be the one that protects your ability to recover, even when nothing visibly changes on the website.

Optimize the work before moving it between platforms. Preserve essential checks. Measure memory with both warm and cold caches. Keep recovery evidence separate from deployment success. And never describe a cost saving or a successful restore that has not actually been measured.

Free 30-min Production AI consultation

Book Now