Self-hosted DBtune
Background
DBtune offers a self-hosted deployment option for enterprise customers. Self-hosting is particularly valuable in two scenarios:
- For organizations requiring an air-gapped environment due to regulatory compliance and information security requirements. If you are not sure if you need an air-gapped environment, you don’t need an air-gapped environment.
- For cases needing specific customizations or integrations that are only possible in a self-managed environment. For example, if you are a software provider you may want to integrate your service more tightly with the DBtune optimizer. This is common for partners who adopt a value added reseller (VAR) or original equipment manufacturer (OEM) commercial model.
The self-hosted deployment delivers the complete feature set of the DBtune SaaS while giving you the added benefits of enhanced security, customization options, and infrastructure control. However, your team will be responsible for maintenance, updates, and infrastructure management.
How to host
There are two parts: 1) the self-hosted DBtune platform, and 2) the DBtune agent.
Self-hosted DBtune container (part 1)
The self-hosted DBtune optimizer product is shipped in one container image called dbtune-self-hosted
, which can be deployed in a Kubernetes cluster, a simple Docker compose environment, or in any runtime that support container images out-of-the-box, such as Heroku. This DBtune optimizer container is akin to the DBtune optimizer as a service (OaaS) product. These two products are equivalent in functionality and they deliver the same expected performance improvement. The only real difference is that the self-hosted optimizer is operated in an air-gapped environment while the OaaS is based on SaaS.
x-common-variables: &common-variables
# You can pass the self-hosted database URL here or the managed one
# The Databases needed are 1 postgres and 1 redis
PG_URL: postgresql://dbtune:password@db:5432/dbtune
CELERY_BROKER_URL: redis://redis:6379/0
# The URL we will access the UI.
FRONTEND_URL: http://localhost:8000
DJANGO_SETTINGS_MODULE: cloud.settings
# Generate one from here: https://djecrety.ir/
DJANGO_SECRET_KEY: 4!@&&8j*marsn&1+dbpfo@9(qa*d8m_*2jyb*a+@2+-+!f&o9q
# Add any other environment variables needed for Django to work
# Example for sending emails with your own SMTP server
# EMAIL_HOST: mailpit
# EMAIL_PORT: 1025
# EMAIL_USE_TLS: false
# EMAIL_HOST_USER: smtp_username
# EMAIL_HOST_PASSWORD: smtp_password
services:
platform:
image: dbtune-self-hosted:latest
platform: linux/amd64
entrypoint: /usr/local/bin/entrypoint.sh
ports:
- "8000:8000"
environment:
<<: *common-variables
healthcheck:
test: ["CMD-SHELL", "curl --fail localhost:8000/api/ping || exit 1"]
interval: 10s
timeout: 60s
retries: 5
depends_on:
db:
condition: service_healthy
networks:
- dbtune-self-hosted-network
worker:
restart: unless-stopped
image: 224344074590.dkr.ecr.eu-north-1.amazonaws.com/dbtune-self-hosted:2.0.0
entrypoint: /usr/local/bin/worker-entrypoint.sh
env_file:
- ../env-files/.env.dev
depends_on:
- platform
- redis
networks:
- dbtune-self-hosted-network
healthcheck:
test: ["CMD-SHELL", "poetry run celery -A cloud inspect ping || exit 1"]
interval: 10s
timeout: 10s
retries: 5
environment:
<<: *common-variables
# Optional containers, you can pass directly URLs for those services
db:
ports:
- "5432:5432"
image: postgres:16
volumes:
- ../volumes/postgres_data:/var/lib/postgresql/data/
environment:
POSTGRES_DB: dbtune
POSTGRES_USER: dbtune
POSTGRES_PASSWORD: password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dbtune"]
interval: 2s
timeout: 5s
retries: 20
networks:
- dbtune-self-hosted-network
redis:
restart: unless-stopped
image: redis:7.0.15-alpine
ports:
- "6379:6379"
networks:
- dbtune-self-hosted-network
volumes:
postgres_data:
networks:
dbtune-self-hosted-network:
driver: bridge
name: dbtune-self-hosted-network
The DBtune API and user interface will be exposed on the assigned IP to the platform
container.
This is a flowchart that explains how the container operates.

Create a superuser
To create a superuser to have access to the DBtune UI, and the back-office provided by Django you can run the following command by connecting to the container of the platform service.
docker compose -f dockerfiles/self-hosted-compose.yaml exec platform poetry run python backend/manage.py createsuperuser
Then follow the instructions to create a superuser.
DBtune agent (part 2)
The DBtune agent requires to be installed and connected to your database. The agent will then communicate with the hosted DBtune container using the internal IP address you assigned to the DBtune container. Please note that this agent is the same as the agent in the SaaS solution — More information can be found in the DBtune documentation. The agent is open-source and written in GoLang.
Downloading the container image
The DBtune team provides access to the Container Registry credentials that are needed to authenticate and download the artifacts.
If your infrastructure is in AWS, the DBtune team will give you the possibility of whitelisting your AWS Account ID. This allows you to fetch the container images without needing any specific additional authentication.
Programmatic access
The DBtune REST API enables you to programmatically retrieve database information and recommendations. The API uses resource-oriented URLs, returns request responses in JSON format, and uses standard HTTP status codes.
To get started, please refer to the DBtune API documentation.
Security
The self-hosted deployment of DBtune works in an air-gapped environment, requiring no internet access. This makes it ideal for Enterprise offline deployments.