{"id":13739,"date":"2025-12-16T12:36:00","date_gmt":"2025-12-16T07:06:00","guid":{"rendered":"https:\/\/www.youstable.com\/blog\/?p=13739"},"modified":"2026-09-07T11:09:06","modified_gmt":"2026-09-07T05:39:06","slug":"optimize-redis-on-linux","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/optimize-redis-on-linux\/","title":{"rendered":"How to Optimize Redis on Linux Server for Faster Performance"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To optimize Redis on a Linux server, upgrade to the latest stable Redis, tune redis.conf (maxmemory, eviction policy, persistence), disable Transparent Huge Pages, set vm.overcommit_memory=1, raise file descriptors and somaxconn, optimize networking, and monitor latency, memory fragmentation, and evictions. Apply systemd limits, run on fast storage, and benchmark changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Optimizing Redis on a Linux server is about aligning Redis configuration, Linux kernel parameters, storage, and networking with your workload. In this guide, I\u2019ll show you exactly how to optimize Redis on <a href=\"https:\/\/www.youstable.com\/blog\/configure-directadmin-on-linux\/\">Linux server<\/a> environments, from redis.conf tuning to kernel tweaks, based on 12+ years of real-world hosting and performance engineering.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"prerequisites-and-quick-checks\"><strong>Prerequisites and Quick Checks<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you tune, establish a baseline and confirm your environment is healthy.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use Redis 7.x or later for improved I\/O, memory, and LFU eviction.<\/li>\n\n\n\n<li>Provision enough RAM so your <em>dataset + overhead<\/em> fits in memory, plus 20\u201330% headroom.<\/li>\n\n\n\n<li>Use a modern Linux kernel (5.x+), SSD\/NVMe storage if using AOF, and stable CPU clocks (disable aggressive power saving).<\/li>\n\n\n\n<li>Run Redis on dedicated instances when possible (avoid noisy neighbors).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Baseline checks\nredis-cli INFO server | egrep 'redis_version|process_id'\nredis-cli INFO memory | egrep 'used_memory_rss|mem_fragmentation_ratio'\nredis-cli INFO stats | egrep 'evicted_keys|keyspace_hits|keyspace_misses'\n\n# OS and hardware snapshot\nuname -a\nlsb_release -a 2&gt;\/dev\/null || cat \/etc\/os-release\nfree -h\nlsblk -o NAME,ROTA,SIZE,TYPE,MOUNTPOINT\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"install-or-upgrade-redis-the-right-way\"><strong>Install or Upgrade Redis the Right Way<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Keep Redis updated. Newer versions bring optimizations, smarter eviction algorithms, and <a href=\"https:\/\/www.youstable.com\/blog\/fix-safaris-cannot-establish-a-secure-connection\/\">security fixes<\/a>. Prefer official repositories or a trusted vendor repo.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Debian\/Ubuntu\nsudo apt-get update &amp;&amp; sudo apt-get install -y redis-server\nsudo systemctl enable --now redis\n\n# RHEL\/CentOS\/Rocky (EPEL or vendor repo)\nsudo dnf install -y redis\nsudo systemctl enable --now redis\n\n# Verify version\nredis-cli --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you compile from source, pin a specific stable version, run Redis under a dedicated user, and use systemd for supervision.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"core-redis-conf-tuning-for-performance\"><strong>Core redis.conf Tuning for Performance<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most performance wins come from proper Redis configuration. Adjust settings to your use case: cache-only, mixed read\/write, or durable data store.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"networking-and-connections\"><strong>Networking and Connections<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Bind only to required interfaces and keep protected-mode on for safety.<\/li>\n\n\n\n<li>Increase backlog and TCP keepalive to handle bursts and long-lived connections.<\/li>\n\n\n\n<li>Use a Unix socket for local apps to reduce TCP overhead.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"memory-and-eviction\"><strong>Memory and Eviction<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set <code>maxmemory<\/code> to cap usage and choose an eviction policy that fits: <em>allkeys-lru<\/em> or <em>allkeys-lfu<\/em> for general caches; <em>volatile-lru\/lfu<\/em> when you expire keys explicitly.<\/li>\n\n\n\n<li>Enable active defragmentation to reduce fragmentation spikes.<\/li>\n\n\n\n<li>Monitor <code>mem_fragmentation_ratio<\/code>; values > 1.5 can indicate tuning needs or memory pressure.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"persistence-strategy-rdb-vs-aof\"><strong>Persistence Strategy (RDB vs AOF)<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Cache-only: disable persistence for the lowest latency and I\/O.<\/li>\n\n\n\n<li>Durability: enable AOF with <code>appendfsync everysec<\/code> (balanced) and RDB snapshots for fast restarts.<\/li>\n\n\n\n<li>Use <code>aof-use-rdb-preamble yes<\/code> and automatic AOF rewrite to keep files small.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"recommended-redis-conf-template\"><strong>Recommended redis.conf (Template)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/redis\/redis.conf (key excerpts)\n\n# Security &amp; networking\nbind 127.0.0.1 ::1\nprotected-mode yes\nport 6379\ntcp-backlog 65535\ntimeout 0\ntcp-keepalive 300\n# For local apps (optional):\n# unixsocket \/run\/redis\/redis.sock\n# unixsocketperm 770\n\n# General\nsupervised systemd\ndatabases 16\nio-threads 4\nio-threads-do-reads yes\n\n# Memory\nmaxmemory &lt;SET_THIS_TO_70-80%_OF_RAM_FOR_REDIS&gt;\nmaxmemory-policy allkeys-lfu\nactive-defrag yes\nactive-defrag-cycle-min 10\nactive-defrag-cycle-max 75\n\n# Expiration &amp; CPU scheduling\nhz 10\ndynamic-hz yes\nactive-expire-effort 5\n\n# Persistence (choose per workload)\nsave \"\"                             # cache-only: disable RDB\n# For durability:\n# save 900 1\n# save 300 10\n# save 60 10000\n\nappendonly no                       # cache-only\n# For durability:\n# appendonly yes\n# appendfsync everysec\n# no-appendfsync-on-rewrite yes\n# auto-aof-rewrite-percentage 100\n# auto-aof-rewrite-min-size 64mb\n# aof-use-rdb-preamble yes\n\n# Background writes\nrdbcompression yes\nrdbchecksum yes\nstop-writes-on-bgsave-error no\n\n# Client buffers (avoid OOM on Pub\/Sub)\nclient-output-buffer-limit normal 0 0 0\nclient-output-buffer-limit pubsub 32mb 8mb 60\n\n# Latency diagnostics (toggle during tests)\n# latency-monitor-threshold 100\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart Redis after changes and validate with <code>redis-cli CONFIG GET *<\/code> to confirm settings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"linux-kernel-and-system-tuning\"><strong>Linux Kernel and System Tuning<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"disable-transparent-huge-pages-thp\"><strong>Disable Transparent Huge Pages (THP)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">THP increases latency and fragmentation for Redis. Disable it permanently.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Disable THP now\necho never | sudo tee \/sys\/kernel\/mm\/transparent_hugepage\/enabled\necho never | sudo tee \/sys\/kernel\/mm\/transparent_hugepage\/defrag\n\n# Persist across reboots (grub)\nsudo sed -i 's\/GRUB_CMDLINE_LINUX=\"\/GRUB_CMDLINE_LINUX=\"transparent_hugepage=never \/' \/etc\/default\/grub\nsudo update-grub &amp;&amp; sudo reboot<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"overcommit-swap-and-memory\"><strong>Overcommit, Swap, and Memory<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set <code>vm.overcommit_memory=1<\/code> to prevent fork failures during RDB\/AOF rewrites.<\/li>\n\n\n\n<li>Minimize swapping: <code>vm.swappiness=1<\/code> and avoid memory overcommit without headroom.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/sysctl.d\/99-redis.conf\nvm.overcommit_memory = 1\nvm.swappiness = 1\nnet.core.somaxconn = 65535\nnet.ipv4.tcp_tw_reuse = 1\nnet.ipv4.tcp_fin_timeout = 15\n\n# Apply\nsudo sysctl --system<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"file-descriptors-and-backlog\"><strong>File Descriptors and Backlog<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Raise <code>nofile<\/code> limits to handle many connections.<\/li>\n\n\n\n<li>Match <code>tcp-backlog<\/code> in redis.conf with <code>net.core.somaxconn<\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># systemd override for Redis service\nsudo systemctl edit redis\n# Then add:\n# &#91;Service]\n# LimitNOFILE=100000\n# TasksMax=infinity\n\nsudo systemctl daemon-reload\nsudo systemctl restart redis\nulimit -n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"numa-and-cpu-affinity\"><strong>NUMA and CPU Affinity<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On multi-socket <a href=\"https:\/\/www.youstable.com\/blog\/install-redis-on-linux\/\">systems, Redis can suffer<\/a> from NUMA imbalance. Interleave memory and pin CPUs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Interleave memory across NUMA nodes (if numactl is available)\nsudo numactl --interleave=all --cpunodebind=0-1 redis-server \/etc\/redis\/redis.conf\n\n# Or set in systemd ExecStart= with numactl wrapper\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"storage-and-filesystem-considerations\"><strong>Storage and Filesystem Considerations<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use SSD\/NVMe for AOF or heavy snapshot workloads; avoid networked storage for low-latency caches.<\/li>\n\n\n\n<li>Use ext4 or XFS with <code>noatime<\/code> mount option to reduce write amplification.<\/li>\n\n\n\n<li>If persistence is critical, isolate Redis on its own disk and enable periodic filesystem TRIM on SSDs.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Example fstab mount option for Redis data volume\nUUID=xxxx \/var\/lib\/redis ext4 defaults,noatime 0 2\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"client-side-optimizations-that-matter\"><strong>Client-Side Optimizations That Matter<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use pipelining for batches; this dramatically reduces round trips.<\/li>\n\n\n\n<li>Prefer binary-safe commands and avoid large multi-MB values that increase latency.<\/li>\n\n\n\n<li>Expire keys you no longer need; memory churn is cheaper than stale data.<\/li>\n\n\n\n<li>Choose data structures wisely: hashes\/sets over large JSON blobs when possible.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"monitoring-benchmarking-and-maintenance\"><strong>Monitoring, Benchmarking, and Maintenance<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run <code>redis-cli INFO<\/code> and track: <code>latency<\/code>, <code>connected_clients<\/code>, <code>used_memory<\/code>, <code>evicted_keys<\/code>, <code>instantaneous_ops_per_sec<\/code>, <code>mem_fragmentation_ratio<\/code>.<\/li>\n\n\n\n<li>Enable and sample the slowlog: <code>slowlog-log-slower-than 10000<\/code> (in microseconds). Inspect with <code>slowlog get 20<\/code>.<\/li>\n\n\n\n<li>Use redis_exporter + Prometheus + Grafana for long-term metrics and alerts.<\/li>\n\n\n\n<li>Benchmark changes with <code>redis-benchmark<\/code> or application-level load tests. Change one variable at a time.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Quick latency and slowlog checks\nredis-cli latency doctor\nredis-cli slowlog get 10 | head -n 50<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"high-availability-and-scaling\"><strong>High Availability and Scaling<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <a href=\"https:\/\/www.youstable.com\/blog\/how-to-setup-redis-on-linux-server\/\">Redis Sentinel<\/a> for automatic failover in master-replica setups.<\/li>\n\n\n\n<li>Adopt Redis Cluster or application-level sharding when a single node\u2019s memory\/CPU becomes a bottleneck.<\/li>\n\n\n\n<li>Consider read replicas for analytics or background jobs to offload traffic from the primary.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"security-settings-that-also-affect-performance\"><strong>Security Settings That Also Affect Performance<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Bind to localhost or private subnets<\/strong>: avoid public exposure. Add a firewall.<\/li>\n\n\n\n<li>Authentication (<code>requirepass<\/code> or ACLs) is essential; minor overhead is worth the risk reduction.<\/li>\n\n\n\n<li><strong>TLS adds CPU overhead<\/strong>: enable only if traffic leaves a trusted network. Prefer a local Unix socket for same-host apps.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"common-bottlenecks-and-quick-wins-checklist\"><strong>Common Bottlenecks and Quick Wins Checklist<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>High latency spikes:<\/strong> disable THP, reduce AOF fsync to <code>everysec<\/code>, enable pipelining.<\/li>\n\n\n\n<li><strong>Evictions or OOM: <\/strong>set <code>maxmemory<\/code> correctly, choose <code>allkeys-lfu<\/code>, prune large values.<\/li>\n\n\n\n<li><strong>Fork failures:<\/strong> set <code>vm.overcommit_memory=1<\/code>, ensure free RAM headroom (20\u201330%).<\/li>\n\n\n\n<li><strong>Connection drops: <\/strong>raise <code>somaxconn<\/code>, <code>tcp-backlog<\/code>, and <code>nofile<\/code> limits.<\/li>\n\n\n\n<li><strong>High fragmentation:<\/strong> enable <code>active-defrag<\/code>, restart during maintenance windows if necessary.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"when-to-choose-managed-optimization\"><strong>When to Choose Managed Optimization<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re running mission-critical workloads and can\u2019t afford trial-and-error, a managed environment helps. At YouStable, our performance-tuned VPS and <a href=\"https:\/\/www.youstable.com\/blog\/tally-on-cloud-vs-local-installation\/\">cloud servers<\/a> ship with sensible Redis defaults, kernel hardening, and proactive monitoring. We\u2019ll help you size RAM, pick a persistence model, and benchmark your stack so you focus on shipping features.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"step-by-step-apply-the-essentials\"><strong>Step-by-Step: Apply the Essentials<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Upgrade Redis to the latest stable release.<\/li>\n\n\n\n<li>Set <code>maxmemory<\/code> and an appropriate <code>maxmemory-policy<\/code>.<\/li>\n\n\n\n<li>Choose persistence: none (cache) or AOF everysec + RDB (durable).<\/li>\n\n\n\n<li>Disable THP; set <code>vm.overcommit_memory=1<\/code>, <code>somaxconn=65535<\/code>, raise <code>nofile<\/code>.<\/li>\n\n\n\n<li>Use Unix sockets for local apps and enable pipelining.<\/li>\n\n\n\n<li>Monitor with redis_exporter; alert on latency, evictions, and fragmentation.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"faqs-optimize-redis-on-linux\"><strong>FAQs<\/strong> &#8211; Optimize Redis on Linux<\/h2>\n\n\n\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"what-is-the-best-maxmemory-policy-for-a-redis-cache\">What is the best maxmemory-policy for a Redis cache?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">For general-purpose caches, <code>allkeys-lfu<\/code> provides excellent hit ratios by evicting least-frequently-used items. If your access patterns are bursty but short-lived, <code>allkeys-lru<\/code> can perform well. For datasets with explicit TTLs, consider <code>volatile-lfu<\/code> or <code>volatile-lru<\/code> so only expiring keys are evicted.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"should-i-use-rdb-or-aof-on-a-linux-server\">Should I use RDB or AOF on a Linux server?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">For pure caching, disable both for the lowest latency. For persistence, use AOF with <code>appendfsync everysec<\/code> plus periodic RDB snapshots. This hybrid offers fast restarts and near-real-time durability with manageable I\/O overhead.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"how-do-i-permanently-disable-transparent-huge-pages\">How do I permanently disable Transparent Huge Pages?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Disable it at runtime with <code>echo never > \/sys\/kernel\/mm\/transparent_hugepage\/enabled<\/code> and persist via GRUB by adding <code>transparent_hugepage=never<\/code> to <code>GRUB_CMDLINE_LINUX<\/code>, then update grub and reboot. Verify after reboot by checking the same sysfs file for \u201cnever\u201d.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"how-many-connections-can-redis-handle-and-how-do-i-raise-it\">How many connections can Redis handle and how do I raise it?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Redis can handle tens of thousands of connections, limited by file descriptors and CPU. Raise limits via systemd (<code>LimitNOFILE=100000<\/code>), increase <code>net.core.somaxconn<\/code>, align <code>tcp-backlog<\/code>, and ensure sufficient CPU. Use connection pooling in clients to reduce overhead.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"which-redis-metrics-indicate-a-healthy-server\">Which Redis metrics indicate a healthy server?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Track latency, instantaneous_ops_per_sec, used_memory, mem_fragmentation_ratio (~1.1\u20131.5), evicted_keys (ideally low), blocked_clients, and fork times. Correlate spikes with AOF rewrites or RDB saves to tune persistence and memory settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With these practices, you\u2019ll consistently achieve lower latency, predictable memory usage, and stable throughput from Redis on Linux. Test changes in staging, benchmark, then roll out gradually\u2014your users will feel the difference.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\n<script type=\"application\/ld+json\">\n\t{\n\t\t\"@context\": \"https:\/\/schema.org\",\n\t\t\"@type\": \"FAQPage\",\n\t\t\"mainEntity\": [\n\t\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"What is the best maxmemory-policy for a Redis cache?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>For general-purpose caches, allkeys-lfu provides excellent hit ratios by evicting least-frequently-used items. If your access patterns are bursty but short-lived, allkeys-lru can perform well. For datasets with explicit TTLs, consider volatile-lfu or volatile-lru so only expiring keys are evicted.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Should I use RDB or AOF on a Linux server?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>For pure caching, disable both for the lowest latency. For persistence, use AOF with appendfsync everysec plus periodic RDB snapshots. This hybrid offers fast restarts and near-real-time durability with manageable I\/O overhead.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"How do I permanently disable Transparent Huge Pages?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Disable it at runtime with echo never > \/sys\/kernel\/mm\/transparent_hugepage\/enabled and persist via GRUB by adding transparent_hugepage=never to GRUB_CMDLINE_LINUX, then update grub and reboot. Verify after reboot by checking the same sysfs file for \u201cnever\u201d.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"How many connections can Redis handle and how do I raise it?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Redis can handle tens of thousands of connections, limited by file descriptors and CPU. Raise limits via systemd (LimitNOFILE=100000), increase net.core.somaxconn, align tcp-backlog, and ensure sufficient CPU. Use connection pooling in clients to reduce overhead.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Which Redis metrics indicate a healthy server?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Track latency, instantaneous_ops_per_sec, used_memory, mem_fragmentation_ratio (~1.1\u20131.5), evicted_keys (ideally low), blocked_clients, and fork times. Correlate spikes with AOF rewrites or RDB saves to tune persistence and memory settings.<\/p><p>With these practices, you\u2019ll consistently achieve lower latency, predictable memory usage, and stable throughput from Redis on Linux. Test changes in staging, benchmark, then roll out gradually\u2014your users will feel the difference.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t]\n\t}\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Optimizing Redis on a <a href=\"https:\/\/www.youstable.com\/blog\/touch-command-in-linux\/\">Linux server<\/a> means aligning the kernel, Redis configuration, and client behavior with your workload. Start by fixing kernel basics like overcommit and THP, then right-size maxmemory, eviction policy, and persistence. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, improve client access with pipelining and locality, and avoid expensive commands on large keys. Finally, monitor latency, memory, and hit ratios continuously so you can tune and scale proactively before performance degrades<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To optimize Redis on a Linux server, upgrade to the latest stable Redis, tune redis.conf (maxmemory, eviction policy, persistence), disable [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":14077,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"iawp_total_views":70,"footnotes":""},"categories":[350,2261],"tags":[],"class_list":["post-13739","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","category-kb-databases"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=13739"}],"version-history":[{"count":1,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13739\/revisions"}],"predecessor-version":[{"id":23094,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13739\/revisions\/23094"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/14077"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=13739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=13739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=13739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}