summary refs log tree commit diff
path: root/nixos/modules/services/databases/redis.nix
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2019-08-30 15:44:01 +0200
committerPeter Simons <simons@cryp.to>2019-08-30 18:10:06 +0200
commitafd448a9fad78fc96a98489d3c49b63ca7b4f454 (patch)
tree13f1d29b22eb51386b8eee1697d383ebf3a4ae1f /nixos/modules/services/databases/redis.nix
parent28dee92fffaa0745d9dce8a70623fa3f04885d08 (diff)
downloadnixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.tar
nixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.tar.gz
nixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.tar.bz2
nixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.tar.lz
nixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.tar.xz
nixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.tar.zst
nixpkgs-afd448a9fad78fc96a98489d3c49b63ca7b4f454.zip
nixos/redis: disable transparent huge pages (TLP) before starting Redis
Diffstat (limited to 'nixos/modules/services/databases/redis.nix')
-rw-r--r--nixos/modules/services/databases/redis.nix17
1 files changed, 16 insertions, 1 deletions
diff --git a/nixos/modules/services/databases/redis.nix b/nixos/modules/services/databases/redis.nix
index 3f2857100f5..37cc179023a 100644
--- a/nixos/modules/services/databases/redis.nix
+++ b/nixos/modules/services/databases/redis.nix
@@ -40,7 +40,12 @@ in
       enable = mkOption {
         type = types.bool;
         default = false;
-        description = "Whether to enable the Redis server.";
+        description = ''
+          Whether to enable the Redis server. Note that the NixOS module for
+          Redis disables kernel support for Transparent Huge Pages (THP),
+          because this features causes major performance problems for Redis,
+          e.g. (https://redis.io/topics/latency).
+        '';
       };
 
       package = mkOption {
@@ -224,6 +229,16 @@ in
 
     environment.systemPackages = [ cfg.package ];
 
+    systemd.services.disable-transparent-huge-pages = {
+      enable = config.services.redis.enable;
+      description = "Disable Transparent Huge Pages (required by Redis)";
+      after = [ "sysinit.target" "local-fs.target" ];
+      before = [ "redis.service" ];
+      wantedBy = [ "redis.service" ];
+      script = "echo never >/sys/kernel/mm/transparent_hugepage/enabled";
+      serviceConfig.Type = "oneshot";
+    };
+
     systemd.services.redis =
       { description = "Redis Server";