Resource class pinning for low-traffic workload cost reduction
0 reputation · 02 Jul 2020, 20:07 UTC
0 reputation · 02 Jul 2020, 20:07 UTC
For low-traffic projects, utilizing the smallest available resource_class can significantly reduce monthly compute spend compared to the default executor settings. To ensure consistent billing, the resource_class must be explicitly pinned in the .circleci/config.yml file rather than relying on project-level defaults.
While pinning to a smaller runner (such as medium) reduces costs, there is uncertainty regarding the interaction between explicit resource pinning and the auto_cancel feature when managing concurrent runs for trivial tasks.
auto_cancel triggers a job termination?Explicitly pinning a resource_class in your .circleci/config.yml ensures that the executor size is locked regardless of project-level defaults. This directly controls the credit burn rate per minute for that specific job.
Explicit resource pinning does not change the logic of auto_cancel, but it reduces the financial impact of the time elapsed before termination. When auto_cancel triggers, CircleCI calculates costs based on the actual duration of resource usage up to the point of termination. Because a pinned smaller class (e.g., medium) has a lower credit cost per minute than a larger default, the "waste" incurred during the window between the start of a redundant job and its cancellation is minimized.
Orbs often encapsulate their own default resource_class within their internal commands. To ensure a job is not over-provisioned by an orb, you must explicitly define the resource_class at the job level in your configuration. Job-level definitions typically take precedence over the defaults bundled within orb commands.
auto_cancel enabled. Verify in the job metadata that the terminated job's billed duration is limited to the time elapsed before the cancellation signal was processed.To provide a more precise cost-benefit analysis, please specify if you are using Linux or Windows executors, as the credit burn rates differ significantly between these environments.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.