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.confto configure the server. -
Use
glance-cache.confto configure the utilities.
The following options are in both configuration files. These options require the same values in both files.
| Option | Description | Default |
|---|---|---|
|
| Base directory where the Image service (glance) stores the cache data. | None, must be set |
|
|
Path to the |
|
|
| Driver used for cache management. |
|
|
|
Cache size when the | 10 GB |
|
| 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
Open your
OpenStackControlPlaneCR file,openstack_control_plane.yaml, and add the following parameters to theglancetemplate:apiVersion: core.openstack.org/v1beta1 kind: OpenStackControlPlane spec: ... glance: template: databaseInstance: openstack databaseUser: glance customServiceConfig: | ... imageCache: size: 10Gi storage: storageRequest: 10Gi storageClass: "" glanceAPIs: default: ...Update the control plane:
$ oc apply -f openstack_control_plane.yaml -n openstackWait until RHOCP creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:$ oc get openstackcontrolplane -n openstackThe
OpenStackControlPlaneresources are created when the status is "Setup complete".提示Append the
-woption to the end of thegetcommand to track deployment progress.