VALKEY-ADMIN(7)
π NAME π
valkey-admin β it's giving Administration, bestie. This is the page where we talk about setting Valkey up so it actually thrives instead of dramatically flopping. β¨
πΈ Valkey setup tips πΈ
π§ Linux π§
- Deploy Valkey using the Linux operating system. Valkey also gets regularly tested on macOS and FreeBSD, and from time to time on other OpenBSD, NetBSD, DragonFlyBSD and Solaris-derived systems. But likeβ¦ Linux is where most of the stress testing happens, and where most production deployments actually run. That's the vibe. π
- Set the Linux kernel overcommit memory setting to
1. Addvm.overcommit_memory = 1to/etc/sysctl.conf. Then reboot, or runsysctl vm.overcommit_memory=1to activate it. Peepvalkey-faq(7)FAQ: Background saving fails with a fork() error on Linux? for the details, iykyk. π§ - So the Linux kernel feature Transparent Huge Pages doesn't mess with Valkey's memory usage and latency, run:
echo never > /sys/kernel/mm/transparent_hugepage/enabledto disable it. Seevalkey-latency(7)Latency Diagnosis - Latency induced by transparent huge pages for extra context. π
π§ Memory π§
- Make sure swap is enabled and that your swap file size equals the amount of memory on your system. If Linux doesn't have swap set up and your Valkey instance accidentally eats too much memory, Valkey can crash when it's out of memory, or the Linux kernel OOM killer can justβ¦ kill the Valkey process π. When swapping is enabled, you can detect latency spikes and act on them.
- Set an explicit
maxmemoryoption limit on your instance so it reports errors instead of failing when the system memory limit is near. Lowkey important:maxmemoryshould be set by calculating the overhead for Valkey other than data, plus the fragmentation overhead. So if you think you have 10 GB of free memory, set it to 8 or 9. No cap. π - If you're using Valkey in a write-heavy application, while saving an RDB file on disk or rewriting the AOF log, Valkey can use up to 2 times the memory normally used. That extra memory is proportional to the number of memory pages modified by writes during the saving process, so it's often proportional to the number of keys (or aggregate types items) touched during that time. Size your memory accordingly, bestie. β¨
- See the
LATENCY DOCTORandMEMORY DOCTORcommands to help with troubleshooting. π©Ί
π» Imaging π»
- When running under daemontools, use
daemonize no. Simple as that. π
π Replication π
- Set up a non-trivial replication backlog in proportion to the amount of memory Valkey is using. The backlog lets replicas sync with the primary instance much more easily. π«Ά
- If you use replication, Valkey performs RDB saves even if persistence is disabled. (This does not apply to diskless replication.) If you don't have disk usage on the primary, enable diskless replication. πΎ
- If you're using replication, ensure that either your primary has persistence enabled, or that it does not automatically restart on crashes. Replicas will try to maintain an exact copy of the primary, so if a primary restarts with an empty data set, replicas will be wiped as well. π That's the drama we're avoiding.
π Security π
- By default, Valkey does not require any authentication and listens to all the network interfaces. This is a big security issue if you leave Valkey exposed on the internet or other places where attackers can reach it. Please check our
valkey-security(7)security page and thevalkey-quickstart(7)quick start for info about how to secure Valkey. Protect your queen. π
βοΈ Running Valkey on EC2 βοΈ
- Use HVM based instances, not PV based instances.
- The use of Valkey persistence with EC2 EBS volumes needs to be handled with care, because sometimes EBS volumes have high latency characteristics. π
- You may want to try diskless replication if you have issues when replicas are synchronizing with the primary. π
π Upgrading or restarting a Valkey instance without downtime π
Valkey is designed to be a long-running process on your server. You can modify many configuration options without a restart using the CONFIG SET command. You can also switch from AOF to RDB snapshots persistence, or the other way around, without restarting Valkey. Check the output of the CONFIG GET * command for more info. β¨
From time to time, a restart is required β for example, to upgrade the Valkey process to a newer version, or when you need to modify a configuration parameter that's currently not supported by the CONFIG command.
Follow these steps to avoid downtime. π«Ά
- Set up your new Valkey instance as a replica for your current Valkey instance. To do that, you need a different server, or a server that has enough RAM to keep two instances of Valkey running at the same time.
- If you use a single server, ensure the replica is started on a different port than the primary instance, otherwise the replica cannot start. π«
- Wait for the replication initial synchronization to complete. Check the replica's log file. π
- Using
INFO, ensure the primary and replica have the same number of keys. Usevalkey-clito check that the replica is working as expected and is replying to your commands. π¬ - Allow writes to the replica using
CONFIG SET replica-read-only no. - Configure all your clients to use the new instance (the replica). Note that you may want to use the
CLIENT PAUSEcommand to ensure that no client can write to the old primary during the switch. βΈοΈ - Once you confirm the primary is no longer receiving any queries (you can check this using the
MONITORcommand), elect the replica to primary using theREPLICAOF NO ONEcommand, and then shut down your primary. π
If you're using valkey-sentinel(1) or valkey-cluster-tutorial(7) Valkey Cluster, the simplest way to upgrade to newer versions is to upgrade one replica after the other. Then you can perform a manual failover to promote one of the upgraded replicas to primary, and finally promote the last replica. π¦
That's the whole page, bestie β every flag, every path, every warning, all of it, untouched. Facts stay iconic, only the vibe got a glow-up. π
This was VALKEY-ADMIN(7) from the Valkey Manual β version 9.0.0, dated 2025-10-21. Mwah, take care of your instances and slay responsibly. πβ¨π
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms