The memcached-automove-extstore script automates the rebalancing of memory pages between slab classes in Memcached with extstore enabled. It connects to the Memcached binary via the text protocol to read statistics and issue commands, using a rolling window of historical data to make decisions and avoid flapping.
Installation:
Ensure Python 3 is available. The script is typically located in the scripts/ directory of the repository.
Basic Usage:
Run the script with the target host and port. By default, it connects to localhost:11211.
./scripts/memcached-automove-extstore --host <host>:<port>
Command-Line Options:
--host HOST:PORT: Host and port to connect to (default: localhost:11211).-s, --sleep SECONDS: Seconds between runs (default: 1).-v, --verbose: Enable verbose output to see decision details.-a, --automove: Enable automatic page rebalancing (dry-run mode is default).-w, --window SIZE: Rolling window size for decision history (default: 30).-r, --ratio RATIO: Ratio limiting distance between low/high class ages (default: 0.8).-f, --free RATIO: Free chunks/pages buffer ratio (default: 0.005).-z, --size SIZE: Item size cutoff for storage (default: 512).
Example: Dry-run with verbose logging:
./scripts/memcached-automove-extstore --host 192.168.1.10:11211 -v
Example: Automatic rebalancing:
./scripts/memcached-automove-extstore --host 192.168.1.10:11211 -a
#!/usr/bin/python3
import argparse
import socket
import sys
parser = argparse.ArgumentParser(description="daemon for rebalancing slabs")
parser.add_argument("--host", help="host to connect to",
default="localhost:11211", metavar="HOST:PORT")
parser.add_argument("-s", "--sleep", help="seconds between runs",
type=int, default="1")
parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("-a", "--automove", action="store_true", default=False,
help="enable automatic page rebalancing")
parser.add_argument("-w", "--window", type=int, default="30",
help="rolling window size for decision history")
parser.add_argument("-r", "--ratio", type=float, default=0.8,
help="ratio limiting distance between low/high class ages")
parser.add_argument("-f", "--free", type=float, default=0.005,
help="free chunks/pages buffer ratio")
parser.add_argument("-z", "--size", type=int, default=512,
help="item size cutoff for storage")
args = parser.parse_args()
host, port = args.host.split(':')
# ... (rest of script logic)
Sources: scripts/memcached-automove-extstore