redis
This commit is contained in:
@@ -40,34 +40,31 @@ let
|
||||
# High-performance settings
|
||||
settings = {
|
||||
# Memory and performance optimizations
|
||||
maxclients = 65000;
|
||||
timeout = 0; # Never timeout connections
|
||||
tcp-keepalive = 60;
|
||||
tcp-backlog = 511;
|
||||
maxclients = mkForce 65000;
|
||||
timeout = mkForce 0; # Never timeout connections
|
||||
tcp-keepalive = mkForce 60;
|
||||
tcp-backlog = mkForce 511;
|
||||
|
||||
# Disable slow operations for performance
|
||||
slowlog-log-slower-than = -1; # Disable slow log
|
||||
slowlog-log-slower-than = mkForce (-1); # Disable slow log
|
||||
|
||||
# Memory optimization
|
||||
maxmemory-policy = "noeviction"; # Don't evict keys
|
||||
maxmemory-policy = mkForce "noeviction"; # Don't evict keys
|
||||
|
||||
# Network optimizations
|
||||
"tcp-nodelay" = "yes";
|
||||
tcp-nodelay = mkForce "yes";
|
||||
|
||||
# Hash optimizations for speed
|
||||
hash-max-ziplist-entries = 512;
|
||||
hash-max-ziplist-value = 64;
|
||||
list-max-ziplist-size = -2;
|
||||
set-max-intset-entries = 512;
|
||||
zset-max-ziplist-entries = 128;
|
||||
zset-max-ziplist-value = 64;
|
||||
|
||||
# Disable key expiration notifications for performance
|
||||
notify-keyspace-events = "";
|
||||
hash-max-ziplist-entries = mkForce 512;
|
||||
hash-max-ziplist-value = mkForce 64;
|
||||
list-max-ziplist-size = mkForce (-2);
|
||||
set-max-intset-entries = mkForce 512;
|
||||
zset-max-ziplist-entries = mkForce 128;
|
||||
zset-max-ziplist-value = mkForce 64;
|
||||
|
||||
# Cluster optimizations
|
||||
cluster-require-full-coverage = "no"; # Allow partial cluster operation
|
||||
cluster-allow-reads-when-down = "yes";
|
||||
cluster-require-full-coverage = mkForce "no"; # Allow partial cluster operation
|
||||
cluster-allow-reads-when-down = mkForce "yes";
|
||||
};
|
||||
};
|
||||
}) (range 0 (masters - 1)));
|
||||
@@ -95,25 +92,24 @@ let
|
||||
appendOnly = false;
|
||||
|
||||
settings = {
|
||||
maxclients = 65000;
|
||||
timeout = 0;
|
||||
tcp-keepalive = 60;
|
||||
tcp-backlog = 511;
|
||||
slowlog-log-slower-than = -1;
|
||||
maxmemory-policy = "noeviction";
|
||||
"tcp-nodelay" = "yes";
|
||||
hash-max-ziplist-entries = 512;
|
||||
hash-max-ziplist-value = 64;
|
||||
list-max-ziplist-size = -2;
|
||||
set-max-intset-entries = 512;
|
||||
zset-max-ziplist-entries = 128;
|
||||
zset-max-ziplist-value = 64;
|
||||
notify-keyspace-events = "";
|
||||
cluster-require-full-coverage = "no";
|
||||
cluster-allow-reads-when-down = "yes";
|
||||
maxclients = mkForce 65000;
|
||||
timeout = mkForce 0;
|
||||
tcp-keepalive = mkForce 60;
|
||||
tcp-backlog = mkForce 511;
|
||||
slowlog-log-slower-than = mkForce (-1);
|
||||
maxmemory-policy = mkForce "noeviction";
|
||||
tcp-nodelay = mkForce "yes";
|
||||
hash-max-ziplist-entries = mkForce 512;
|
||||
hash-max-ziplist-value = mkForce 64;
|
||||
list-max-ziplist-size = mkForce (-2);
|
||||
set-max-intset-entries = mkForce 512;
|
||||
zset-max-ziplist-entries = mkForce 128;
|
||||
zset-max-ziplist-value = mkForce 64;
|
||||
cluster-require-full-coverage = mkForce "no";
|
||||
cluster-allow-reads-when-down = mkForce "yes";
|
||||
|
||||
# Replica-specific settings
|
||||
replica-read-only = "no"; # Allow writes to replicas in cluster mode
|
||||
replica-read-only = mkForce "no"; # Allow writes to replicas in cluster mode
|
||||
};
|
||||
};
|
||||
}) (range 0 (replicasPerMaster - 1))
|
||||
@@ -185,24 +181,40 @@ in
|
||||
# System-wide performance optimizations
|
||||
boot.kernel.sysctl = {
|
||||
# Network optimizations
|
||||
"net.core.somaxconn" = "65535";
|
||||
"net.core.netdev_max_backlog" = "5000";
|
||||
"net.ipv4.tcp_max_syn_backlog" = "65535";
|
||||
"net.ipv4.tcp_fin_timeout" = "30";
|
||||
"net.ipv4.tcp_keepalive_time" = "1200";
|
||||
"net.ipv4.tcp_keepalive_intvl" = "15";
|
||||
"net.ipv4.tcp_keepalive_probes" = "5";
|
||||
"net.core.somaxconn" = mkForce "65535";
|
||||
"net.core.netdev_max_backlog" = mkForce "5000";
|
||||
"net.ipv4.tcp_max_syn_backlog" = mkForce "65535";
|
||||
"net.ipv4.tcp_fin_timeout" = mkForce "30";
|
||||
"net.ipv4.tcp_keepalive_time" = mkForce "1200";
|
||||
"net.ipv4.tcp_keepalive_intvl" = mkForce "15";
|
||||
"net.ipv4.tcp_keepalive_probes" = mkForce "5";
|
||||
|
||||
# Memory optimizations
|
||||
"vm.swappiness" = "1";
|
||||
"vm.overcommit_memory" = "1";
|
||||
"vm.dirty_background_ratio" = "5";
|
||||
"vm.dirty_ratio" = "10";
|
||||
"vm.swappiness" = mkForce "1";
|
||||
"vm.overcommit_memory" = mkForce "1";
|
||||
"vm.dirty_background_ratio" = mkForce "5";
|
||||
"vm.dirty_ratio" = mkForce "10";
|
||||
|
||||
# File system optimizations
|
||||
"fs.file-max" = "2097152";
|
||||
"fs.file-max" = mkForce "2097152";
|
||||
};
|
||||
|
||||
# System-wide ulimit settings for Redis
|
||||
security.pam.loginLimits = [
|
||||
{
|
||||
domain = "*";
|
||||
type = "soft";
|
||||
item = "nofile";
|
||||
value = "1048576";
|
||||
}
|
||||
{
|
||||
domain = "*";
|
||||
type = "hard";
|
||||
item = "nofile";
|
||||
value = "1048576";
|
||||
}
|
||||
];
|
||||
|
||||
# Service-level optimizations for all Redis instances
|
||||
systemd.services =
|
||||
let
|
||||
@@ -213,8 +225,8 @@ in
|
||||
) (range 0 (cfg.masters - 1)));
|
||||
|
||||
serviceConfig = {
|
||||
# Resource limits
|
||||
LimitNOFILE = "65535";
|
||||
# Resource limits - set much higher for Redis cluster
|
||||
LimitNOFILE = "1048576";
|
||||
LimitNPROC = "65535";
|
||||
LimitMEMLOCK = "infinity";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user