Configure a Dedicated Cloud Service for a Datastore
You can configure a dedicated Cassandra or Postgres cloud service and customize datastore settings for your application or environment.
Configuring additional services, such as a dedicated Cassandra or Postgres cloud service, increases computing resources and cost.
Configure a dedicated Cassandra cloud service
Complete the following steps to configure a dedicated Cassandra cloud service with customizable settings:
- Set the cloud service configuration for the datastore
- Ensure the cloud service for datastore availability
- Check the cloud service status
Set the Cassandra cloud service configuration for the datastore
If the datastore serves an environment, navigate to the C3 AI Console at the environment level. If the datastore serves an application, navigate to the C3 AI Console at the application level.
Run the following script to set the configuration:
var cassTest = CassandraDB.make().withRoleAndSeq();
// Run when you start a new application or environment, and use the next ID sequence number:
// var cassTest = cassTest.withId("<CassandraPodID>")
var c = cassTest.config();
c = c.withField("heapSize", "12000M" ); // Default value 512M
c = c.withField("storageSize", "1024Gi" ); // Default value 30Gi
c = c.withField("ringSize", 3 ); // Default value 1
c = c.withField("storageClassName", "<StorageClass>" ); // Set to "C3-ssd" for GCP, "gp2" for AWS, or "default" for Azure deployments.
c = c.withField("cpuLimits", "8");
c = c.withField("cpuRequests", "8");
c = c.withField("memoryLimits", "64Gi");
c = c.withField("memoryRequests", "64Gi");
c.setConfig() // Sets configuration for environment or application
// Validate configuration
console.log(cassTest);
console.log(cassTest.config());
console.log(cassTest.config().allConfigOverrides());Review and set the configuration values in the script. This script does the following:
- Creates an instance of the CassandraDB Type.
- Specifies the application or environment ID if you terminate or start a new application or environment.
- Sets values for the following resource allocation and performance tuning configurations:
heapSize: The amount of memory allocated to the Java heap for Cassandra. A too low value might cause frequent garbage collection. A too high value might cause infrequent garbage collection and result in unresponsiveness during the garbage collection period.storageSize: The size of persistent volume attached to the Cassandra pod, where Cassandra stores SSTables and other data files.ringSize: The number of nodes in the Cassandra ring. This value affects how the system partitions and replicates data cross the cluster.storageClassName: The Kubernetes StorageClass for provisioning persistent volumes. Set to "C3-ssd" for GCP, "gp2" for AWS, or "default" for Azure deployments. See Storage Classes in the Kubernetes documentation to learn more.cpuLimits: The maximum amount of CPU the Cassandra pod can use.cpuRequests: The amount of CPU allocated to the pod.memoryLimits: The maximum amount of memory the pod can use.memoryRequests: The minimum amount of memory the Cassandra pod is guaranteed to have.
- Sets the configuration for the environment when you run in the environment C3 AI Console, or for the application when you run in the application C3 AI Console.
- Validates the configuration.
Ensure the Cassandra cloud service for datastore availability
After you set the configuration, ensure the Cassandra cloud service to make sure the datastore is available.
If you do not ensure the datastore cloud service, the configuration causes your environment or application to enter a corrupt state. Do not skip this step.
Run the following command to ensure the service for the datastore:
cassTest.ensureService({
waitForReady: true,
restartAllServers: true
})This command does the following:
waitForReady: truemakes the command wait until all Cassandra pods fully start and are in a ready state.restartAllServers: truerestarts all Cassandra server pods and applies configuration changes.
Check Cassandra cloud service status
After you ensure the Cassandra cloud service, confirm it is available.
Run the following code to check the cloud service status:
cassandras = CassandraDB.listForEnv(C3.env());
cassandras = CassandraDB.listForApp(C3.app());
cassandras[0].status // Should return `available`This code does the following:
- Checks if the cloud service is configured for the environment.
- Checks if the cloud service is configured for the application.
- Verifies if the cloud service is available.
Or, run this code to check the cloud service status:
Cassandra.inst().ping()This code retrieves the instance of the configured Cassandra connection and sends a request to the cloud service to verify if it is reachable and responsive.
Run the following code to check if the environment or application can fetch data:
NormalizedTimeseries.fetch();If the datastore is running, this code returns a non-null object.
In C3 AI Studio, you can also navigate to Admin > Services to view information on cloud services such as Cassandra. See View Cloud Services and Manage Resources to learn more.
Terminate the Cassandra instance
To avoid data corruption, you cannot terminate the Cassandra instance when the associated application or environment has not been terminated.
To terminate a Cassandra instance, terminate the associated application or environment. See Manage Environments and Applications in C3 AI Studio to learn how to terminate an application or environment.
When you terminate a Cassandra instance, you do not delete its data. To delete the data, contact C3 AI Operations.
Configure a dedicated Postgres cloud service
The C3 AI Agentic Platform supports a containerized or managed Postgres cloud service:
- Containerized cloud service: Hosted by C3 AI
- Managed cloud service: Hosted by an external cloud provider and managed by customer
To set up a managed Postgres datastore, contact C3 AI Operations.
Complete the following steps to configure a containerized Postgres datastore:
- Set the cloud service configuration for the datastore
- Ensure the cloud service for datastore availability
- Check the cloud service status
Set the cloud service configuration for the datastore
If the datastore serves an environment, navigate to the C3 AI Console at the environment level. If the datastore serves an application, navigate to the C3 AI Console at the application level.
Run the following script to set the configuration:
var pg = PostgresDB.make().withRoleAndSeq();
// Run when you start a new application or environment, and use the next ID sequence number:
// var pg = pg.withId("<PostgresDatastoreId>")
var c = pg.config();
c = c.withField("persistenceSize", "1024Gi");
c = c.withField("resourcesLimitsCpu", "8");
c = c.withField("resourcesRequestsCpu", "8");
c = c.withField("resourcesLimitsMemory", "52Gi"); // Set to "52Gi" for GCP, and "64Gi" others
c = c.withField("resourcesRequestsMemory", "52Gi"); // Set to "52Gi" for GCP, and "64Gi" others
c.setConfig()// Sets configuration for environment or application
// Validate configuration
console.log(pg);
console.log(pg.config());
console.log(pg.config().allConfigOverrides());Review and set the configuration values in the script. This script does the following:
- Creates an instance of the PostgresDB Type.
- Sets values for the following resource allocation and performance tuning configurations:
persistenceSize: The size of persistent volume used to store Postgres data.resourcesLimitsCpu: The maximum amount of CPU the Postgres pod can use.resourcesRequestsCpu: The amount of CPU reserved to ensure the container can start and run reliably.resourcesLimitsMemory: The limit for how much memory the container can use.resourcesRequestsMemory: The amount of memory reserved to ensure the container can start and run reliably.
- Sets the configuration for the environment when you run in the environment C3 AI Console, or for the application when you run in the application C3 AI Console.
- Validates the configuration.
Ensure the Postgres cloud service for datastore availability
After you set the configuration, ensure the Postgres cloud service to make sure the datastore is available.
If you do not ensure the datastore cloud service, the configuration causes your environment or application to enter a corrupt state. Do not skip this step.
Run the following command to ensure the cloud service for the datastore:
pg.ensureService(CloudServiceStartSpec.make({notManaged: true})); This command ensures the Postgres cloud service is running and specifies that C3 AI does not manage the service.
Restart all nodes
After you ensure the cloud service for the datastore, restart all nodes in the environment and application that you are setting up a Postgres datastore for.
To restart all nodes in the application, run the following code.
C3.app().restart()To restart all nodes in the environment, run the following code.
C3.env().restart()After you restart all nodes in the node pool, the application or environment picks up the Postgres configuration.
Check Postgres cloud service status
After you ensure the cloud service for the datastore, confirm it is available.
Run the following code to check the cloud service status:
postgres = PostgresDB.listForEnv(C3.env());
postgres = PostgresDB.listForApp(C3.app());
postgres[0].status // Should return `available`This code does the following:
- Checks if the cloud service is configured for the environment.
- Checks if the cloud service is configured for the application.
- Verifies if the cloud service is available.
Run the following code to check if the environment or application can fetch data:
User.fetch()If the database is running, this code returns a non-null object.
In C3 AI Studio, you can also navigate to Admin > Services to view information on cloud services such as Cassandra. See View Cloud Services and Manage Resources to learn more.
Terminate the Postgres instance
To avoid data corruption, you cannot terminate the Postgres instance when the associated application or environment has not been terminated.
To terminate a Postgres instance, terminate the associated application or environment. See Manage Environments and Applications in C3 AI Studio to learn how to terminate an application or environment.
When you terminate a Postgres instance, you do not delete its data. To delete the data, contact C3 AI Operations.