www.cnblogs.com/ruiyqinrui

开源、架构、Linux C/C++/python AI BI 运维开发自动化运维。 春风桃李花 秋雨梧桐叶。“力尽不知热 但惜夏日长”。夏不惜,秋不获。@ruiY--秦瑞

python爬虫,C编程,嵌入式开发.hadoop大数据,桉树,onenebula云计算架构.linux运维及驱动开发.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  2912 随笔 :: 9 文章 :: 51 评论 :: 185万 阅读

The Glance Image Cache

The Glance API server may be configured to have an optional local image cache. A local image cache stores a copy of image files, essentially enabling multiple API servers to serve the same image file, resulting in an increase in scalability due to an increased number of endpoints serving an image file.

This local image cache is transparent to the end user – in other words, the end user doesn’t know that the Glance API is streaming an image file from its local cache or from the actual backend storage system.

Managing the Glance Image Cache

While image files are automatically placed in the image cache on successful requests to GET/images/<IMAGE_ID>, the image cache is not automatically managed. Here, we describe the basics of how to manage the local image cache on Glance API servers and how to automate this cache management.

Controlling the Growth of the Image Cache

The image cache has a configurable maximum size (the image_cache_max_size configuration file option). The image_cache_max_size is an upper limit beyond which pruner, if running, starts cleaning the images cache. However, when images are successfully returned from a call to GET/images/<IMAGE_ID>, the image cache automatically writes the image file to its cache, regardless of whether the resulting write would make the image cache’s size exceed the value ofimage_cache_max_size. In order to keep the image cache at or below this maximum cache size, you need to run the glance-cache-pruner executable.

The recommended practice is to use cron to fire glance-cache-pruner at a regular interval.

Cleaning the Image Cache

Over time, the image cache can accumulate image files that are either in a stalled or invalid state. Stalled image files are the result of an image cache write failing to complete. Invalid image files are the result of an image file not being written properly to disk.

To remove these types of files, you run the glance-cache-cleaner executable.

The recommended practice is to use cron to fire glance-cache-cleaner at a semi-regular interval.

Prefetching Images into the Image Cache

Some installations have base (sometimes called “golden”) images that are very commonly used to boot virtual machines. When spinning up a new API server, administrators may wish to prefetch these image files into the local image cache to ensure that reads of those popular image files come from a local cache.

To queue an image for prefetching, you can use one of the following methods:

  • If the cache_manage middleware is enabled in the application pipeline, you may callPUT /queued-images/<IMAGE_ID> to queue the image with identifier <IMAGE_ID>

    Alternately, you can use the glance-cache-manage program to queue the image. This program may be run from a different host than the host containing the image cache. Example usage:

    $> glance-cache-manage --host=<HOST> queue-image <IMAGE_ID>
    

    This will queue the image with identifier <IMAGE_ID> for prefetching

Once you have queued the images you wish to prefetch, call the glance-cache-prefetcherexecutable, which will prefetch all queued images concurrently, logging the results of the fetch for each image.

Finding Which Images are in the Image Cache

You can find out which images are in the image cache using one of the following methods:

  • If the cachemanage middleware is enabled in the application pipeline, you may callGET /cached-images to see a JSON-serialized list of mappings that show cached images, the number of cache hits on each image, the size of the image, and the times they were last accessed.

    Alternately, you can use the glance-cache-manage program. This program may be run from a different host than the host containing the image cache. Example usage:

    $> glance-cache-manage --host=<HOST> list-cached
    
  • You can issue the following call on *nix systems (on the host that contains the image cache):

    $> ls -lhR $IMAGE_CACHE_DIR
    

    where $IMAGE_CACHE_DIR is the value of the image_cache_dir configuration variable.

    Note that the image’s cache hit is not shown using this method.

Manually Removing Images from the Image Cache

If the cachemanage middleware is enabled, you may call DELETE /cached-images/<IMAGE_ID> to remove the image file for image with identifier <IMAGE_ID> from the cache.

Alternately, you can use the glance-cache-manage program. Example usage:

$> glance-cache-manage --host=<HOST> delete-cached-image <IMAGE_ID>

http://docs.openstack.org/developer/glance/cache.html

posted on   秦瑞It行程实录  阅读(723)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2014-12-09 kvm中运行kvm
2014-12-09 umount.nfs device busy day virsh extend diskSpace, attachDisk
2014-12-09 ultravnc
2014-12-09 openNebula dubug
www.cnblogs.com/ruiyqinrui
点击右上角即可分享
微信分享提示