docs/mintlify/guides/deploy/gcp.mdx
import { Callout, Danger } from '/snippets/callout.mdx';
<Callout> Chroma Cloud, our fully managed hosted service is here. [Sign up for free](https://trychroma.com/signup?utm_source=docs-gcp). </Callout>You can deploy Chroma on a long-running server, and connect to it remotely.
For convenience, we have provided a very simple Terraform configuration to experiment with deploying Chroma to Google Compute Engine.
<Danger>Chroma and its underlying database need at least 2GB of RAM,
which means it won't fit on the instances provided as part of the
GCP "always free" tier. This template uses an e2-small instance, which
costs about two cents an hour, or $15 for a full month, and gives you 2GiB of memory. If you follow these
instructions, GCP will bill you accordingly.
In this guide we show you how to secure your endpoint using Chroma's native authentication support. Alternatively, you can put it behind GCP API Gateway or add your own authenticating proxy. This basic stack doesn't support any kind of authentication; anyone who knows your server IP will be able to add and query for embeddings.
</Danger> <Danger>By default, this template saves all data on a single volume. When you delete or replace it, the data will disappear. For serious production use (with high availability, backups, etc.) please read and understand the Terraform template and use it as a basis for what you need, or reach out to the Chroma team for assistance.
</Danger>In your GCP project, create a service account for deploying Chroma. It will need the following roles:
Create a JSON key file for this service account, and download it. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your JSON key file:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
Download Terraform and follow the installation instructions for your OS.
Create a chroma.tfvars file. Use it to define the following variables for your GCP project ID, region, and zone:
project_id="<your project ID>"
region="<your region>"
zone="<your zone>"
Download our GCP Terraform configuration to the same directory as your chroma.tfvars file. Then run the following commands to deploy your Chroma stack.
Initialize Terraform:
terraform init
Plan the deployment, and review it to ensure it matches your expectations:
terraform plan -var-file chroma.tfvars
If you did not customize our configuration, you should be deploying an e2-small instance.
Finally, apply the deployment:
terraform apply -var-file chroma.tfvars
If you want to use a machine type different from the default e2-small, in your chroma.tfvars add the machine_type variable and set it to your desired machine:
machine_type = "e2-medium"
After a few minutes, you can get the IP address of your instance with
terraform output -raw chroma_instance_ip
import chromadb
chroma_client = chromadb.HttpClient(
host="<Your Chroma instance IP>",
port=8000
)
chroma_client.heartbeat()
import { ChromaClient } from "chromadb";
const chromaClient = new ChromaClient({
host: "<Your Chroma instance IP>",
port: 8000,
});
chromaClient.heartbeat();
use chroma::{ChromaHttpClient, ChromaHttpClientOptions};
let mut options = ChromaHttpClientOptions::default();
options.endpoint = "http://<Your Chroma instance IP>:8000".parse()?;
let chroma_client = ChromaHttpClient::new(options);
chroma_client.heartbeat().await?;
To destroy the stack and remove all GCP resources, use the terraform destroy command.
terraform destroy -var-file chroma.tfvars
Chroma is instrumented with OpenTelemetry hooks for observability. We currently only export OpenTelemetry traces. These should allow you to understand how requests flow through the system and quickly identify bottlenecks. Check out the observability docs for a full explanation of the available parameters.
To enable tracing on your Chroma server, simply define the following variables in your chroma.tfvars:
chroma_otel_collection_endpoint = "api.honeycomb.com"
chroma_otel_service_name = "chromadb"
chroma_otel_collection_headers = "{'x-honeycomb-team': 'abc'}"