Skip to content

Commit 6757a9c

Browse files
committed
Add option to place etcd data dir on RAM disk
Seems like for etcd-heavy services like Kubernetes, the fsync performance of gate VM's are too low [1]. This commit implements an option to put etcd data directory on RAM disk (tmpfs) to work this around. [1] http://lists.openstack.org/pipermail/openstack-discuss/2019-January/001849.html Change-Id: I5a17099cb9d6941b1a009dc82daefd2c7946d892
1 parent 7adc401 commit 6757a9c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/etcd3

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ set +o xtrace
2727
ETCD_DATA_DIR="$DATA_DIR/etcd"
2828
ETCD_SYSTEMD_SERVICE="devstack@etcd.service"
2929
ETCD_BIN_DIR="$DEST/bin"
30+
# Option below will mount ETCD_DATA_DIR as ramdisk, which is useful to run
31+
# etcd-heavy services in the gate VM's, e.g. Kubernetes.
32+
ETCD_USE_RAMDISK=$(trueorfalse False ETCD_USE_RAMDISK)
33+
ETCD_RAMDISK_MB=${ETCD_RAMDISK_MB:-512}
3034

3135
if is_ubuntu ; then
3236
UBUNTU_RELEASE_BASE_NUM=`lsb_release -r | awk '{print $2}' | cut -d '.' -f 1`
@@ -89,6 +93,9 @@ function cleanup_etcd3 {
8993

9094
$SYSTEMCTL daemon-reload
9195

96+
if [[ "$ETCD_USE_RAMDISK" == "True" ]]; then
97+
sudo umount $ETCD_DATA_DIR
98+
fi
9299
sudo rm -rf $ETCD_DATA_DIR
93100
}
94101

@@ -98,6 +105,9 @@ function install_etcd3 {
98105
# Create the necessary directories
99106
sudo mkdir -p $ETCD_BIN_DIR
100107
sudo mkdir -p $ETCD_DATA_DIR
108+
if [[ "$ETCD_USE_RAMDISK" == "True" ]]; then
109+
sudo mount -t tmpfs -o nodev,nosuid,size=${ETCD_RAMDISK_MB}M tmpfs $ETCD_DATA_DIR
110+
fi
101111

102112
# Download and cache the etcd tgz for subsequent use
103113
local etcd_file

0 commit comments

Comments
 (0)