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

glance image cache的更多相关文章

  1. glance cache

    用在多个glance API server 中,对相同的image文件提供服务.该cache对用户透明. 配置文件有一个image_cache_max_size,超过的话image cache会被修剪 ...

  2. Glance组件解析

    1 Glance基本框架图 组件 描述 A client 任何使用Glance服务的应用. REST API 通过REST方式暴露Glance的使用接口. Database Abstraction L ...

  3. openstack (4)---部署Glance镜像服务,Nova计算服务

    一.Glance Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚拟机镜像的metadata及获取 ...

  4. The Boot Process at a Glance x86/x64系统启动过程解析

    哥又来干体力活了.人肉翻译一下: The Boot Process at a Glance This section explains the boot process in sufficient d ...

  5. 安装glance

    在控制节点上执行 controllerHost='controller' MYSQL_PASSWD='m4r!adbOP' GLANCE_PASSWD='glance1234!' 1.创建数据库 my ...

  6. ASP.NET Core 折腾笔记二:自己写个完整的Cache缓存类来支持.NET Core

    背景: 1:.NET Core 已经没System.Web,也木有了HttpRuntime.Cache,因此,该空间下Cache也木有了. 2:.NET Core 有新的Memory Cache提供, ...

  7. [Java 缓存] Java Cache之 DCache的简单应用.

    前言 上次总结了下本地缓存Guava Cache的简单应用, 这次来继续说下项目中使用的DCache的简单使用. 这里分为几部分进行总结, 1)DCache介绍; 2)DCache配置及使用; 3)使 ...

  8. Spring cache简单使用guava cache

    Spring cache简单使用 前言 spring有一套和各种缓存的集成方式.类似于sl4j,你可以选择log框架实现,也一样可以实现缓存实现,比如ehcache,guava cache. [TOC ...

  9. 笔记:Memory Notification: Library Cache Object loaded into SGA

    笔记:Memory Notification: Library Cache Object loaded into SGA在警告日志中发现一些这样的警告信息:Mon Nov 21 14:24:22 20 ...

随机推荐

  1. CODEVS 1004四子连棋

    [题目描述 Description] 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白色棋子,7颗黑色棋子,有两个空白地带,任何一颗黑白棋子都可以向上下左右四个方向移动到相邻的空格,这叫行棋一步,黑 ...

  2. AJAX技术的核心

    //创建一个XMLHttpRequest对象 ,利用此对象与服务器进行通信 是AJAX技术的核心 /** * 获取XmlHttpRequest对象 */ function getXMLHttpRequ ...

  3. objective_C 优缺点

    objective-c语言的优缺点 objc优点: 1) Cateogies 2) Posing3) 动态识别4) 指标计算5)弹性讯息传递6) 不是一个过度复杂的 C 衍生语言7) Objectiv ...

  4. vim 分屏 screen

    上下分割,并打开一个新的文件. :sp filename 左右分割当前打开的文件. Ctrl+W v 左右分割,并打开一个新的文件. :vsp filename 移动光标 Vi中的光标键是h, j, ...

  5. PHP漏洞全解(一)-PHP网站的安全性问题

    本文主要介绍针对PHP网站常见的攻击方式,包括常见的sql注入,跨站等攻击类型.同时介绍了PHP的几个重要参数设置.后面的系列文章将站在攻击者的角度,为你揭开PHP安全问题,同时提供相应应对方案. 针 ...

  6. 介绍一个超好用的HICHARTS扩展插件

    因为需要,所以HIGHCHARTS了解一下是很有必要的. 但原始应用确实效率不行. 刚好,现在有个需求是从一系列的JSON里抽出表格数据,再显示图形. jquery.highchartsTable.j ...

  7. 【无聊放个模板系列】POJ2752 EXKMP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  8. 如何用CURL并解释JSON

    CURL *curl; CURLcode res; struct curl_slist *headers=NULL; // init to NULL is important headers = cu ...

  9. C语言动态内存管理

    1-概述 动态存储管理的基本问题是:系统如何按请求分配内存,如何回收内存再利用.提出请求的用户可能是系统的一个作业,也可能是程序中的一个变量. 空闲块 未曾分配的地址连续的内存区称为“空闲块”. 占用 ...

  10. 内核驱动中常见的miscdevice、platform_device、platform_driver

    最近在看驱动模型,是越看越糊涂,以前接触比较多的都是一些字符驱动,对字符驱动的框架有一定的了解.后来因为想在驱动中实现设备文件的创建,又了解了一下,sysfs文件系统和udev设备文件系统(这两个是两 ...