]> git.proxmox.com Git - ceph.git/blob - ceph/doc/rbd/rbd-persistent-cache.rst
import 15.2.0 Octopus source
[ceph.git] / ceph / doc / rbd / rbd-persistent-cache.rst
1 =======================
2 RBD Persistent Cache
3 =======================
4
5 .. index:: Ceph Block Device; Persistent Cache
6
7 Shared, Read-only Parent Image Cache
8 ====================================
9
10 `Cloned RBD images`_ from a parent usually only modify a small portion of
11 the image. For example, in a VDI workload, the VMs are cloned from the same
12 base image and initially only differ by hostname and IP address. During the
13 booting stage, all of these VMs would re-read portions of duplicate parent
14 image data from the RADOS cluster. If we have a local cache of the parent
15 image, this will help to speed up the read process on one host, as well as
16 to save the client to cluster network traffic.
17 RBD shared read-only parent image cache requires explicitly enabling in
18 ``ceph.conf``. The ``ceph-immutable-object-cache`` daemon is responsible for
19 caching the parent content on the local disk, and future reads on that data
20 will be serviced from the local cache.
21
22 .. note:: RBD shared read-only parent image cache requires the Ceph Nautilus release or later.
23
24 .. ditaa:: +--------------------------------------------------------+
25 | QEMU |
26 +--------------------------------------------------------+
27 | librbd (cloned images) |
28 +-------------------+-+----------------------------------+
29 | librados | | ceph--immutable--object--cache |
30 +-------------------+ +----------------------------------+
31 | OSDs/Mons | | local cached parent image |
32 +-------------------+ +----------------------------------+
33
34
35 Enable RBD Shared Read-only Parent Image Cache
36 ----------------------------------------------
37
38 To enable RBD shared read-only parent image cache, the following Ceph settings
39 need to added in the ``[client]`` `section`_ of your ``ceph.conf`` file.
40
41 ``rbd parent cache enabled = true``
42
43
44 Immutable Object Cache Daemon
45 =============================
46
47 The ``ceph-immutable-object-cache`` daemon is responsible for caching parent
48 image content within its local caching directory. For better performance it's
49 recommended to use SSDs as the underlying storage.
50
51 The key components of the daemon are:
52
53 #. **Domain socket based IPC:** The daemon will listen on a local domain
54 socket on start up and wait for connections from librbd clients.
55
56 #. **LRU based promotion/demotion policy:** The daemon will maintain
57 in-memory statistics of cache-hits on each cache file. It will demote the
58 cold cache if capacity reaches to the configured threshold.
59
60 #. **File-based caching store:** The daemon will maintain a simple file
61 based cache store. On promotion the RADOS objects will be fetched from
62 RADOS cluster and stored in the local caching directory.
63
64 On opening each cloned rbd image, ``librbd`` will try to connect to the
65 cache daemon over its domain socket. If it's successfully connected,
66 ``librbd`` will automatically check with the daemon on the subsequent reads.
67 If there's a read that's not cached, the daemon will promote the RADOS object
68 to local caching directory, so the next read on that object will be serviced
69 from local file. The daemon also maintains simple LRU statistics so if there's
70 not enough capacity it will delete some cold cache files.
71
72 Here are some important cache options correspond to the following settings:
73
74 - ``immutable_object_cache_path`` The immutable object cache data directory.
75
76 - ``immutable_object_cache_max_size`` The max size for immutable cache.
77
78 - ``immutable_object_cache_watermark`` The watermark for the cache. If the
79 capacity reaches to this watermark, the daemon will delete cold cache based
80 on the LRU statistics.
81
82 The ``ceph-immutable-object-cache`` daemon is available within the optional
83 ``ceph-immutable-object-cache`` distribution package.
84
85 .. important:: ``ceph-immutable-object-cache`` daemon requires the ability to
86 connect RADOS clusters.
87
88 ``ceph-immutable-object-cache`` daemon should use a unique Ceph user ID.
89 To `create a Ceph user`_, with ``ceph`` specify the ``auth get-or-create``
90 command, user name, monitor caps, and OSD caps::
91
92 ceph auth get-or-create client.ceph-immutable-object-cache.{unique id} mon 'allow r' osd 'profile rbd-read-only'
93
94 The ``ceph-immutable-object-cache`` daemon can be managed by ``systemd`` by specifying the user
95 ID as the daemon instance::
96
97 systemctl enable ceph-immutable-object-cache@immutable-object-cache.{unique id}
98
99 The ``ceph-immutable-object-cache`` can also be run in foreground by ``ceph-immutable-object-cache`` command::
100
101 ceph-immutable-object-cache -f --log-file={log_path}
102
103 .. _Cloned RBD Images: ../rbd-snapshot/#layering
104 .. _section: ../../rados/configuration/ceph-conf/#configuration-sections
105 .. _create a Ceph user: ../../rados/operations/user-management#add-a-user
106