| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Databases such as PostgreSQL and Cassandra make extensive use of the OS page cache to serve queries. Maintenance events like reboots result in the database software operating against an empty or almost empty page cache, hampering performance until the cache can fill.
happycache is a utility to quicky re-fill ths OS page cache using the pages that were present previously. A happy cache makes for a happy database!
$ happycache
Usage: happycache (dump|load) args...
dump
print out a map of pages that are currently in the page cache by recursively
walking a directory.
directory: the directory to walk
(default=current working directory)
load [threads] [filename]
load pages into the cache using a happycache dump file
filename: the happycache dump file to read (default=stdin)
threads: the number of threads to read with (default=32)
happycache dump files contain the addresses (not the data) of the pages in the cache. They are designed to be highly compressible, so we'll use gzip to cut the map file down to size. In this example, we'll dump the page cache of a Cassandra data directory.
cassandra@box:/var/lib/cassandra$ happycache dump root@box:/var/lib/cassandra# reboot cassandra@box:/var/lib/cassandra# happycache load
We can use happycache load across servers. In the example below, we rsync files from the /var/lib/cassandra directory on box1 to the /var/lib/cassandra/subdir directory on box2. Because the happycache dump file encodes relative paths, it has no problem working under the modified path.
cassandra@box1:/var/lib/cassandra$ happycache dump root@box2:/var/lib/cassandra/subdir# rsync -a box1:/var/lib/cassandra/ . cassandra@box2:/var/lib/cassandra/subdir# happycache load
The need for happycache can be avoided in many cases by using cgroups to limit the amount of page cache an application can consume. For instance, one can run mycommand in a memory cgroup with 50MB of memory like so:
$ sudo cgcreate -g memory:backups -a $USER -t $USER $ cgset -r memory.limit_in_bytes=52428800 backups $ cgexec -g memory:backups mycommand
| Back | FazBrowse Home | New Git URL |