7.2. Improving Image service scalability with caching


Use the Image service API (glanceAPI) caching mechanism to store copies of images on glanceAPI servers and retrieve them automatically. With image caching, the API does not need to retrieve the same image from back-end storage multiple times. The automatic retrieval of image copies improves scalability and performance by reducing the load on resources.

You use two files to manage image cache:

  • Use glance-api.conf to configure the server.
  • Use glance-cache.conf to configure the utilities.

The following options are in both configuration files. These options require the same values in both files.

Expand
表 7.1. Configuration options for image cache
OptionDescriptionDefault

image_cache_dir

Base directory where the Image service (glance) stores the cache data.

None, must be set

image_cache_sqlite_db

Path to the sqlite file database to be used for cache management. This path is a relative path from the image_cache_dir directory.

cache.db

image_cache_driver

Driver used for cache management.

sqlite

image_cache_max_size

Cache size when the glance-cache-pruner removes the oldest images to reduce the number of bytes until it is below this value.

10 GB

image_cache_stall_time

Amount of time an incomplete image stays in the cache until it is deleted.

1 day

You can use a cron job to run glance-cache-pruner to remove the oldest images at regular intervals. You can also use a cron job to run glance-cache-cleaner to clean up image files that are in stalled or invalid states because the image cache writes failed to complete or because image files were not written successfully to disk.

The following values are specific to the glance-cache.conf file and are only required for the prefetcher to run correctly.

  • filesystem_store_datadir: Use this parameter if you are using a filesystem store. The parameter points to where the data is kept.
  • filesystem_store_datadirs: Use this parameter to point to multiple filesystem stores.

In Red Hat OpenStack Services on OpenShift (RHOSO), you can queue images for immediate caching instead of using periodic jobs to prefetch queued images as in previous Red Hat OpenStack Platform versions.

7.2.1. Enabling Image service caching for performance

To enable image caching in the Image service (glance), you specify the size assigned to the cache by adding the Size parameter to the imageCache section of the glance template in your OpenStackControlPlane custom resource (CR) file.

Procedure

  1. Open your OpenStackControlPlane CR file, openstack_control_plane.yaml, and add the following parameters to the glance template:

    apiVersion: core.openstack.org/v1beta1
    kind: OpenStackControlPlane
    spec:
        ...
      glance:
        template:
          databaseInstance: openstack
          databaseUser: glance
          customServiceConfig: |
            ...
          imageCache:
            size: 10Gi
          storage:
            storageRequest: 10Gi
            storageClass: ""
          glanceAPIs:
            default:
      ...
  2. Update the control plane:

    $ oc apply -f openstack_control_plane.yaml -n openstack
  3. Wait until RHOCP creates the resources related to the OpenStackControlPlane CR. Run the following command to check the status:

    $ oc get openstackcontrolplane -n openstack

    The OpenStackControlPlane resources are created when the status is "Setup complete".

    提示

    Append the -w option to the end of the get command to track deployment progress.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部