Health Checks

Docker Compose

The simples form of health check is to use the healthcheck directive in the docker-compose.yml file. This is useful if you are deploying Chroma alongside other services that may depend on it.

1. version: '3.9'

3. networks:
4. net:
5. driver: bridge

7. services:
8. server:
9. image: server
10. build:
11. context: .
12. dockerfile: Dockerfile
13. volumes:
14. # Be aware that indexed data are located in "/chroma/chroma/"
15. # Default configuration for persist_directory in chromadb/config.py
16. # Read more about deployments: https://docs.trychroma.com/deployment
17. - chroma-data:/chroma/chroma
18. command: "--workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30"
19. environment:
20. - IS_PERSISTENT=TRUE
21. - CHROMA_SERVER_AUTH_PROVIDER=${CHROMA_SERVER_AUTH_PROVIDER}
22. - CHROMA_SERVER_AUTH_CREDENTIALS_FILE=${CHROMA_SERVER_AUTH_CREDENTIALS_FILE}
23. - CHROMA_SERVER_AUTH_CREDENTIALS=${CHROMA_SERVER_AUTH_CREDENTIALS}
24. - CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER=${CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER}
25. - CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER=${CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER}
26. - PERSIST_DIRECTORY=${PERSIST_DIRECTORY:-/chroma/chroma}
27. - CHROMA_OTEL_EXPORTER_ENDPOINT=${CHROMA_OTEL_EXPORTER_ENDPOINT}
28. - CHROMA_OTEL_EXPORTER_HEADERS=${CHROMA_OTEL_EXPORTER_HEADERS}
29. - CHROMA_OTEL_SERVICE_NAME=${CHROMA_OTEL_SERVICE_NAME}
30. - CHROMA_OTEL_GRANULARITY=${CHROMA_OTEL_GRANULARITY}
31. - CHROMA_SERVER_NOFILE=${CHROMA_SERVER_NOFILE}
32. ports:
33. - 8000:8000
34. healthcheck:
35. test: [ "CMD", "/bin/bash", "-c", "cat < /dev/null > /dev/tcp/localhost/8001" ]
36. interval: 30s
37. timeout: 10s
38. retries: 3
39. networks:
40. - net
41. volumes:
42. chroma-data:
43. driver: local

Kubernetes

In kubernetes you can use the livenessProbe and readinessProbe to check the health of the server. This is useful if you are deploying Chroma in a kubernetes cluster.

1. apiVersion: apps/v1
2. kind: Deployment
3. metadata:
4. name: chroma
5. labels:
6. app: chroma
7. spec:
8. replicas: 1
9. selector:
10. matchLabels:
11. app: chroma
12. template:
13. metadata:
14. labels:
15. app: chroma
16. spec:
17. containers:
18. - name: chroma
19. image: <chroma-image>
20. ports:
21. - containerPort: 8000
22. livenessProbe:
23. httpGet:
24. path: /api/v1
25. port: 8000
26. initialDelaySeconds: 5
27. periodSeconds: 5
28. readinessProbe:
29. httpGet:
30. path: /api/v1
31. port: 8000
32. initialDelaySeconds: 5
33. periodSeconds: 5
34. startupProbe:
35. httpGet:
36. path: /api/v1
37. port: 8000
38. failureThreshold: 3
39. periodSeconds: 60
40. initialDelaySeconds: 60

Alternative to the httpGet you can also use tcpSocket:

1. readinessProbe:
2. tcpSocket:
3. port: 8000
4. failureThreshold: 3
5. timeoutSeconds: 30
6. periodSeconds: 60
7. livenessProbe:
8. tcpSocket:
9. port: 8000
10. failureThreshold: 3
11. timeoutSeconds: 30
12. periodSeconds: 60
13. startupProbe:
14. tcpSocket:
15. port: 8000
16. failureThreshold: 3
17. periodSeconds: 60
18. initialDelaySeconds: 60

February 14, 2024