Menu
Slack Engineering·April 14, 2025

Optimizing CI/CD Pipelines with Conditional Frontend Builds and Internal CDNs

Slack's DevXP team significantly optimized their CI/CD pipeline for a large monorepo by implementing conditional frontend builds and leveraging an internal CDN. This strategy reduced unnecessary build times and storage costs by detecting changes with `git diff` and reusing prebuilt, production-ready assets, thereby improving developer experience and pipeline efficiency.

Read original on Slack Engineering

The Challenge: Inefficient E2E Testing in a Monorepo

Slack faced a common challenge in their CI/CD pipeline for a large monorepo: frontend builds were consistently consuming half of the 10-minute end-to-end (E2E) test run, even when no frontend code had changed. This inefficiency led to thousands of unnecessary builds weekly, resulting in significant cloud storage costs (terabytes of duplicate data in AWS S3) and substantial developer wait times (thousands of hours weekly). The problem highlighted a crucial bottleneck in a frequently executed, critical part of their development workflow.

Architectural Solution: Conditional Builds and Asset Reuse

To address the inefficiencies, Slack implemented a two-pronged solution leveraging existing tools and a smarter build strategy. The core idea was to avoid redundant work by conditionally building the frontend and reusing artifacts when possible. This approach demonstrates a practical application of optimizing build systems in a large-scale, complex development environment.

  1. Conditional Frontend Builds: The pipeline was enhanced to first determine if a fresh frontend build was necessary. This was achieved by using `git diff` with 3-dot notation to compare the current branch's latest common commit with `main`. If frontend-related changes were detected, a new build job was triggered; otherwise, it was skipped.
  2. Prebuilt Assets and Internal CDN: When a frontend build was skipped, the system located and utilized an existing, production-ready frontend build from AWS S3. These prebuilt assets were then served to the E2E testing environment via an internal Content Delivery Network (CDN). This ensured that tests ran against current and consistent assets without the overhead of rebuilding.
💡

System Design Takeaway

When designing CI/CD pipelines, consider the cost of unnecessary computations. Introducing conditional logic and leveraging artifact caching (like using an internal CDN for prebuilt assets) can drastically reduce resource consumption, build times, and improve developer productivity, especially in monorepo environments with frequent commits.

Impact and Results

The optimization efforts yielded significant improvements across several metrics. The number of unnecessary frontend builds was reduced by 60%, leading to hundreds of hours saved monthly in developer wait times and several terabytes of AWS S3 storage savings. The overall E2E pipeline build time decreased from approximately 10 minutes to 2 minutes. Beyond performance, the change also unexpectedly led to a reduction in test flakiness, demonstrating how pipeline optimizations can enhance reliability.

CI/CDDevOpsMonorepoFrontend BuildsAWS S3CDNGitPipeline Optimization

Comments

Loading comments...