Couchbase Capella’s Cluster On/Off feature allows users to pause and resume their clusters seamlessly, without permanently deleting the data, helping optimise cloud expenses and improve operational efficiency.

In this blog, we’ll explore how this feature works and how you can automate it using Terraform.

Users have two options for managing cluster availability:

    • On-Demand On/Off – Manually pause and resume clusters as needed.
    • Scheduled On/Off – Automate pausing/resuming clusters at specific dates and time zones.

Turning off (pausing) a cluster

    • Stops all cluster services.
    • Persists data, configuration, and metadata.
    • Frees compute resources to reduce costs while keeping storage intact.

Turning on (resuming) a cluster

    • Restores the cluster from a paused state.
    • Restarts services and makes data accessible again.
    • Allows clients to reconnect and resume operations seamlessly.

Why use the cluster on/off feature?

  1. Saves computational costs and optimises based on usage:
    • When a cluster is turned off, compute resources (e.g., CPU, RAM) are not billed, reducing infrastructure costs significantly.
    • When a cluster is OFF, you only pay the OFF amount (mostly storage and management costs).
    • Helps align costs with actual usage instead of paying for idle resources.
  1. Reduces operational overhead:
    • Eliminates the need for manual cluster provisioning and teardown.
    • Users can easily resume a paused cluster without reconfiguring or redeploying resources.
  1. Persistence of data and cost-efficient development/testing:
    • Data, schema (buckets, scopes, collections), indexes, users,  allow lists, and backups remain intact when a cluster is paused.
    • Ensures no loss of configuration when resuming operations.
    • Developers can pause non-production environments outside of working hours. This prevents unnecessary costs in CI/CD pipelines, staging, or UAT environments.

Cost optimization

One of the simplest and most effective ways to reduce operational costs is by turning off clusters when they are not in use. We will consider the use case of an AWS cluster with 3 nodes (Data, Index and Query) using a Developer Pro Plan in Couchbase Capella, with the configuration of 2 vCPUs, 16 GB RAM, disk size of 50GB, disk type GP3, and IOPS 3000.

When this cluster is kept online 24/7, it incurs a monthly compute cost of $1,497.60 under the pay-as-you-go model. However, many development clusters are only needed during working hours. By simply shutting down the cluster for 12 hours each day, such as overnight, teams can save $705.60 per month, amounting to a 47% reduction in compute costs. This makes a strong case for automating cluster downtime to optimise cloud spending without impacting developer productivity.

In environments with multiple clusters or development environments that do not require round-the-clock availability, by scheduling downtime for non-essential clusters, teams can reallocate their budgets more effectively, investing in areas that directly impact business outcomes.


Getting started: deploy an on/off schedule using the Terraform provider

The Capella Terraform Provider allows users to manage Capella deployments programmatically, automating resource orchestration. Let’s go through a simple tutorial to deploy an On/Off schedule in Capella through the Terraform Provider.

To learn more about how to turn off or turn on the cluster on demand using Terraform, please refer to the examples and README provided in this repository. There is a step-by-step overview of how to switch the cluster on/off on demand.

In addition to the cluster on/off feature, an App Service can also be turned on/off on demand. Please refer to the following documentation and the Terraform provider examples for more information.

What you’ll learn

    1. The steps to configure the files and understand the commands required to run the Terraform scripts.
    2. A step-by-step tutorial on deploying a Cluster On/Off schedule in Capella using the provider.

Prerequisites

Before you begin, ensure you have:

    1. Terraform version >= 1.5.2
    2. Go version >= 1.2.0
    3. Capella paid account
    4. Capella cluster – You can either create a Couchbase cluster using the provider, the  Capella UI, or the Capella Management API and use the corresponding organization_id, project_id, and cluster_id to create the on/off schedule.
    5. Authentication APIKey – You can create the API key using the Capella UI or the Capella Management API. You must create an API key that has the right set of roles associated with it, depending on the scope of the resources managed by the provider.

For information on setting the authorization and authentication, please refer to the Terraform repository and this blog post.


Step 1: Configuration

Create the variables

  1. Create a file named variables.tf and add the following variable definitions. We will use these variables within our config file.
  2. Create a file named terraform.template.tfvars and add the following lines. Here, we specify the values of key variables associated with the deployment.
  3. Create a file named capella.tf and add the following configuration to create the On/Off schedule for an existing Capella cluster in a project:

Step 2: Deploy and Manage the Schedule

Initialize the Terraform provider

Terraform must be initialized the very first time you use the provider:

Review the Terraform plan

Use the following command to review the resources that will be deployed:

You should see output similar to the following while creating an on/off schedule for an existing cluster:

Execute the Terraform plan

Deploy the Couchbase Capella resources using the following command:

Type “yes” if the plan looks good.

Note: It will take a few minutes to deploy the resources if you are creating a project, deploying a cluster and creating an on/off schedule for it.

It would look like this on the Capella UI:

 

Destroy the schedule


References

Author

Posted by Paulomee De - Software Engineer

Leave a reply