In addition to the standard PostgreSQL in-memory shared buffers, AlloyDB Omni disk cache enables storing buffers on fast storage such as solid-state drives (SSDs). Disk caching accelerates data retrieval in AlloyDB Omni installations with data directories located on slower storage.
Like PostgreSQL shared buffers, AlloyDB Omni disk cache is non-persistent, which means cached data is lost on restart.
By default, AlloyDB Omni disk cache uses all storage reported by the file system. You can define the amount of storage reserved for caching data using the omni_disk_cache_file_size parameter.
Enable AlloyDB Omni disk cache
To enable disk cache, see the following section:
Enable disk cache on a local volume
If you want to use a local volume, you don't have to create a persistent volume. You can use the following optimization instead.
To enable disk cache on a local volume for your database, do the following:
Modify your database cluster manifest to add the
ultraFastCacheattribute to thefeaturessection of thespecsection:DBCluster: metadata: name: CLUSTER_NAME spec: databaseVersion: "18.3.0" primarySpec: features: ultraFastCache: cacheSize: DISK_CACHE_SIZE localVolume: path: "LOCAL_VOLUME_PATH" ...
Replace the following:
CLUSTER_NAME: the name of your database cluster.DISK_CACHE_SIZE: the size of the cache—for example,100Gi. It must be greater thanshared_buffers. This field is optional. If you don't specify the value of this field, AlloyDB Omni uses all space left on the disk.LOCAL_VOLUME_PATH: the path to the local volume—for example,/mnt/disks/raid/0.
Reapply the manifest.
Apply the changes using your preferred orchestrator interface:
Ansible
If you're managing your AlloyDB Omni RPM orchestrator infrastructure directly using Ansible, it triggers updates by running the appropriate playbook and passing the selected
update_actionas an extra variable.Sample file for
update.yml:--- - hosts: localhost vars: update_action: "update_resource_spec" ansible_user: your_ssh_user ansible_ssh_private_key_file: ~/path/to/private-key roles: - role: google.alloydbomni_orchestrator.updateRun the Ansible command:
ansible-playbook -i DEPLOYMENT_SPECIFICATION update.yml -e resource_spec="DBCLUSTER_SPECIFICATION"Replace the following variables:
DEPLOYMENT_SPECIFICATION: path to the deployment specification you created in Install AlloyDB Omni components.DBCLUSTER_SPECIFICATION: path to your cluster specification.
alloydbctlalloydbctl apply -d DEPLOYMENT_SPECIFICATION -r DBCLUSTER_SPECIFICATIONReplace the following variables:
DEPLOYMENT_SPECIFICATION: path to the deployment specification you created in Install AlloyDB Omni components.DBCLUSTER_SPECIFICATION: path to your cluster specification.
Verify the disk cache configuration
After enabling AlloyDB Omni disk cache, verify that the disk cache is accessed by monitoring read and write activity to the disks using available utilities like iotop or iostat.
Additionally, you can check if the AlloyDB Omni disk cache is open.
To verify the disk cache configuration for AlloyDB Omni, use the following command.
cat LOG_FILE_PATH | grep "opened omni disk cache"Replace LOG_FILE_PATH with
the path where AlloyDB Omni logs are being redirected to.
If your disk caching is configured correctly, the Successfully opened omni disk cache ... message displays in the logs.