Connecting client applications
Learn how to connect your applications to utilize caching.
Overview
Connecting client applications to DB Optimizer (DBO) requires changes to the connection string. Specifically, these are:
hostname- update the hostname or IP to connect to the DBOProxycomponent, rather than directly to the database.port- update the port property to5432for PostgreSQL and3306for MySQL.
When you first connect your applications to DBO, the cache will operate in passthrough mode by default. This allows you to:
- Monitor your database traffic and query patterns
- Analyze potential caching benefits
- Ensure everything is working correctly before enabling active caching
Once you're comfortable with the setup and have reviewed the metrics, you can switch to Auto or Manual mode to start benefiting from DBO's caching capabilities.
Postgres and MySQL
Connection string
In this method, you will update your database connection string in your application code:
-
In the DBO console, navigate to the Databases table.
-
Click on the name of the logical database you want to connect to.

Click on a database with a deployed cache
- In the drawer that opens on the right, locate the Endpoints tab.
- Copy the connection string and use it in your application.
Testing PostgreSQL Connectivity
CLI Example
psql "host=[Proxy host or IP] \
sslmode=require \
port=9010 \
user='dbuser' \
dbname='dbname'Cluster setup
When configuring a database cluster (e.g., Amazon Aurora) or using read replicas, it is recommended to create a dedicated endpoint for each instance. This ensures that every database instance hostname has a corresponding DBO endpoint, enabling a smooth and seamless transition to DBO. Example:
In this case, if your application connects to two separate endpoints (e.g., writer-product and reader-product), these endpoints should be updated with the corresponding values listed below. DBO is shared across all members of your cluster, allowing it to observe cache invalidations and traffic from every instance. This improves the overall caching efficiency.
When a request is made to the reader endpoint and results in a cache miss, DBO forwards the query to the appropriate read replica. The same logic applies to the writer endpoint, where cache misses are directed to the primary instance.
Updated about 1 month ago
