Getting started

Understand the financial benefits of Cast AI database optimization.

This guide will walk you through setting up Cast AI DB Optimizer (DBO) for your database. DBO uses a two-phase approach that allows you to safely monitor your database traffic on the Cast platform before enabling active caching.

Overview

Cast DBO operates in two phases:

Phase 1: Passthrough Mode

  • Monitor your database traffic without any interference
  • Analyze query patterns and potential caching benefits
  • View performance metrics to understand optimization opportunities
  • Zero risk to your production environment

Phase 2: Active Caching

  • Enable intelligent caching based on your comfort level
  • Choose between Auto mode (AI-driven) or Manual mode (full control)
  • Realize performance improvements and cost savings
  • Continue monitoring with full visibility into cache performance

Choose Your Setup Path

DBO offers two ways to get started:

Option 1: Manual Configuration

Suited for:

  • Any PostgreSQL database (self-hosted, cloud-hosted, managed services)
  • Custom database deployments
  • Non-AWS environments

Continue with Manual Configuration

Option 2: AWS Auto-Discovery

Suited for:

  • AWS RDS instances
  • AWS Aurora databases
  • When you want automatic database discovery
  • Simplified setup with performance insights

Go to AWS Setup Guide


Manual Configuration Setup

Follow these steps to manually configure DBO for your database.

Phase 1: Setting Up Passthrough Mode

Step 1: Create a New Cache

  1. Log in to the Cast AI console.
  2. Navigate to DB OptimizerCaches in the left sidebar.

  1. Click Add cache to begin creating your cache configuration.

Step 2: Configure Cache Settings

In the cache creation modal, you'll need to provide the following information:

  1. Cache configuration name: Enter a descriptive name for your cache configuration within DBO (e.g., "production-db-cache").

  2. Database Engine: Select your database type from the dropdown. Currently, PostgreSQL is supported.

  3. Add endpoints: Configure your database connection:

    • Host: Enter your database hostname or IP address
    • Port: Default is 5432 for PostgreSQL
    • Name: Provide a name for this endpoint
  4. Add databases: Specify which logical databases to cache:

    • Enter the exact database name(s) you want to optimize
    • You can add multiple databases that exist on the same instance
  5. Click Create deployment to proceed.

Step 3: Deploy the Cache Components

After creating the cache configuration, you'll be prompted to deploy the DBO components to your Kubernetes cluster:

  1. Copy the provided deployment script.
  2. Run the script in your Kubernetes cluster's terminal or cloud shell.
  3. Wait for the deployment to complete (typically takes 1-2 minutes).

The script will deploy the configured DBO cache into your cluster, in the castai-db-optimizer namespace.

📘

Note

You can choose to deploy the cache at a later time by clicking the in the cache row and selecting Deploy components. This will generate the same deployment script, which you can run whenever you're ready.

Step 4: Verify Deployment

Once deployed, your cache will appear in the Caches list:

The cache will show:

  • Status: Should display Ready when successfully deployed
  • Type: Will show Manual Component for manually created caches
  • Metrics: Initially showing 0 values as no traffic is flowing yet (the DBO proxy is not yet connected to your application)

You will notice that the number of Cached databases is 0 until DBO is connected to your application and caching is enabled (phase 2).

Step 5: Update Application Connection Strings

To start monitoring your database traffic, update your application's connection string to route through the DBO proxy:

  1. Click on your cache name to view details.

  2. Click on the logical database in the list at the bottom of the page

  3. In the database page that opens, click View configuration in the top-right:

  4. Locate the connection string in the Connection Settings section.

  5. Copy the new connection string.

  6. Update your application configuration to use this connection string instead of your direct database connection.

For detailed connection instructions, see Connecting client applications.

Step 6: Passthrough Mode

With your application connected, DBO will begin operating in passthrough mode:

In this mode:

  • All queries pass through to your database without being cached
  • DBO analyzes query patterns and builds intelligence
  • You can view metrics showing:
    • Total queries: Total number of database queries processed.
    • Cacheable queries: Read queries that are eligible for caching.
    • Read/Write distribution: The distribution of read and write queries processed by the database

This allows you to understand the potential benefits before enabling active caching.

Phase 2: Enabling Active Caching

Once you're comfortable with the metrics and potential benefits shown in passthrough mode, you can enable active caching.

Step 1: Access Cache Settings

  1. Repeat steps 1-3 from Step 5: Connecting Your Application to view the configuration for a particular database.
  2. Locate the Database Caching section.

Step 2: Choose Your Caching Mode

DBO offers two caching modes:

Auto Mode (Recommended)

  • AI-driven caching that automatically optimizes all queries
  • No configuration required
  • Continuously adapts to your workload patterns

Manual Mode

  • Full control over what gets cached
  • Only caches queries per specific rules

Step 3: Enable Caching

  1. Select your desired caching mode (Auto or Manual).
  2. The change takes effect immediately.
  3. Monitor the cache performance metrics to see the impact.

Step 4: Fine-tune with Override Rules (Optional)

In either mode, you can create override rules for specific queries or tables:

  • Fixed TTL: Set specific cache duration for queries
  • Dynamic: Let DBO determine optimal TTL (default in Auto mode)
  • Caching Off: Disable caching for specific queries

For detailed configuration options, see Cache Configuration Guide.

Monitoring Performance

Once active caching is enabled, monitor key metrics:

  • Hit Rate: Percentage of queries served from cache
  • Cache Hits: Number of queries served without hitting the database
  • Time Saved: Cumulative time saved by serving from cache

Next Steps