@cryptotaxi247 / infra-1 / commits / 173d9f1d

* Set some resource limits on Apache.

svn path=/configurations/trunk/tud/; revision=34594

Eelco Dolstra committed Jul 30, 2012 at 18:26 UTC 173d9f1d5512b647dae37d6b0032110f344b8c42
1 file changed +31
cartman.nix
+31
@@ -277,6 +277,12 @@ rec {
277
278 StartServers 15
279 '';
280 +
281 + phpOptions =
282 + ''
283 + #max_execution_time = 2
284 + memory_limit = "32M"
285 + '';
286
287 servedFiles =
288 [ { urlPath = "/releases.css";
@@ -647,4 +653,29 @@ rec {
653 exec = "${pkgs.dnsmasq}/bin/dnsmasq --conf-file=${confFile}";
654 };
655
656 + # Use cgroups to limit Apache's resources.
657 + services.cgroups.enable = true;
658 +
659 + services.cgroups.groups =
660 + ''
661 + mount {
662 + cpu = /sys/fs/cgroup/cpu;
663 + memory = /sys/fs/cgroup/memory;
664 + }
665 +
666 + group httpd {
667 + cpu {
668 + cpu.shares = "1000";
669 + }
670 + memory {
671 + memory.limit_in_bytes = "1024M";
672 + memory.memsw.limit_in_bytes = "1024M";
673 + }
674 + }
675 + '';
676 +
677 + services.cgroups.rules =
678 + ''
679 + wwwrun:httpd cpu,memory httpd
680 + '';
681 }