As your team increases its adoption of Testcontainers Cloud, there might be a point where you wish to optimize your usage. This article describes some useful techniques.
Fine-tune turbo mode
Turbo mode allows you to run tests in parallel by requesting multiple workers. In general, this is a net-positive as your CI pipelines run faster, and overall usage stays relatively constant. For example, in an ideal case, a pipeline that previously took 15 minutes running on a single worker might instead take 5 minutes when being parallelized across 3 workers. However it's also possible to request more workers than is useful, increasing total usage without achieving significant speed improvements. When that happens, you can reduce the number of requested workers (e.g. --max-concurrency flag) and confirm that the duration stays constant, effectively reclaiming some unproductive usage.
Terminate workers eagerly when your tests finish
By default, workers remain active for a certain period of inactivity before they shutdown to provide a smooth user experience, particularly on desktop. In CI pipelines it's often possible to know that a specific pipeline or job will no longer need access to its Testcontainers Cloud worker(s) once it completes. In such cases, it's possible to optimize usage by eagerly terminating worker(s) on agent shutdown. To do so, simply pass the --terminate flag as an argument when starting the agent. Alternatively, you could call the terminate command while the agent is still running.
Note: available in version 1.3.32 and beyond.