CircleCI credits are a bit of a black box until you hit a wall, and then suddenly you’re staring at a bill that seems to have materialized out of thin air.
Let’s see what’s actually happening when your builds run. Imagine this: you push code, and CircleCI spins up a runner, installs your dependencies, compiles your code, runs your tests, and deploys. Each of those steps consumes resources – CPU, memory, disk I/O, network bandwidth. CircleCI bundles those resource consumptions into "credits."
Here’s a look at a real pipeline run in CircleCI, not as a conceptual diagram, but as it appears in the UI. Notice the different jobs and their durations. Each of these contributes to your credit usage.
# Example: A typical build run in CircleCI UI
#
# Pipeline: 123456789
# Branch: main
# Commit: abcdef1234567890abcdef1234567890abcdef12
#
# Build # 987654321
# Job: build_and_test (Linux, 2 vCPU, 4GB RAM)
# - Step 1: Checkout code (0.1 credits)
# - Step 2: Install dependencies (2.5 credits)
# - Step 3: Run tests (5.0 credits)
# - Step 4: Build artifact (3.0 credits)
# Total Job Credits: 10.6 credits
#
# Job: deploy (Linux, 2 vCPU, 4GB RAM)
# - Step 1: Authenticate with cloud provider (0.5 credits)
# - Step 2: Deploy to staging (7.0 credits)
# Total Job Credits: 7.5 credits
#
# Total Pipeline Credits: 18.1 credits
The core problem CircleCI credits solve is abstracting away the complexities of underlying infrastructure. Instead of provisioning, scaling, and managing your own build servers, you’re paying for a service that does it for you. The "credits" are the unit of exchange for this managed service.
Internally, CircleCI uses a fleet of execution environments, often containerized, that are provisioned on demand. When your pipeline starts, CircleCI allocates resources for your chosen executor (e.g., Linux with specific CPU/RAM) and charges you based on the duration and the resource class of that executor. The more powerful the executor (more CPU, more RAM), the more credits it consumes per hour.
You control your billing primarily through your .circleci/config.yml file and your organization’s CircleCI settings.
- Executor Resource Class: The
resource_classparameter in yourconfig.ymlis your main lever. Choosingmedium(2 vCPU, 4GB RAM) will cost more per hour thansmall(1 vCPU, 2GB RAM).jobs: build_and_test: docker: image: cimg/base:stable resource_class: medium # <-- This directly impacts credit usage steps: # ... your steps ... - Parallelism: Running jobs in parallel can speed up your pipeline but increases the number of executors running concurrently, thus increasing credit consumption.
workflows: version: 2 build_and_test_workflow: jobs: - build_and_test: matrix: parameters: os: [linux, windows] # Example of parallelism - deploy: requires: - build_and_test - Pipeline Frequency: More commits, more branches, more pull requests – each can trigger a pipeline, accumulating credit usage. This isn’t something you change in
config.ymlbut rather in your development workflow. - Build Cache: While not directly a credit charge, an inefficient cache can lead to longer dependency installation times, which does consume more credits.
- Orb Usage: Some Orbs might have their own internal logic that influences execution time or resource needs.
The amount of credits a job consumes isn’t just about its wall-clock time; it’s about the size of the machine it’s running on. A job that takes 10 minutes on a large executor might consume more credits than a job that takes 20 minutes on a medium executor, because the large executor has a higher per-minute credit cost.
The most surprising thing about CircleCI credits is how much they can vary even for seemingly identical tasks if you’re not paying close attention to the resource_class and executor type. A complex test suite might run fine on medium, but if you accidentally bump it to xlarge for a single, infrequent job, you’re paying a premium for that entire job’s duration, even if the extra resources aren’t fully utilized.
Once you’ve optimized your resource_class settings and understand your pipeline’s concurrency, you’ll start to notice that certain steps consistently take longer than others. This is where you can dig into the individual job logs and identify bottlenecks.
The next concept you’ll likely grapple with is optimizing build times themselves, often through techniques like caching dependencies more effectively and parallelizing tests within a single job.