test
[hcoop/zz_old/ikiwiki] / UsingResourceLimits.mdwn
CommitLineData
ee25310d 1To prevent users from monopolizing system resources with runaway processes, we impose ulimits in a way that will lead to your processes dying mysteriously if they try to exceed them. You can see what limits are being imposed in your current login by running the following command, with output shown:\r
2\r
3{{{you@new:~$ ulimit -aS\r
4core file size (blocks, -c) 0\r
5data seg size (kbytes, -d) unlimited\r
6file size (blocks, -f) unlimited\r
7max locked memory (kbytes, -l) unlimited\r
8max memory size (kbytes, -m) unlimited\r
9open files (-n) 1024\r
10pipe size (512 bytes, -p) 8\r
11stack size (kbytes, -s) unlimited\r
12cpu time (seconds, -t) unlimited\r
13max user processes (-u) 20\r
14virtual memory (kbytes, -v) 100000}}}\r
15\r
16These limits are known as '''soft limits'''. Similarly, you can see your '''hard limits''' by running `ulimit -aH`. Soft limits are the limits that actually apply to your processes at a given time. You have the option to increase your soft limits to any values no greater than your hard limits. For instance, if you really need to run 21 processes at once instead of just 20, you can do this, because your hard limit is probably 50. The proper command is:\r
17\r
18{{{ulimit -Su 21}}}\r
19\r
20The `-S` indicates that you are setting a soft limit, and `u` is the name of a resource limit kind, taken from the output above.\r
21\r
22You can even ''decrease'' your available resources, to put yourself in a self-imposed sandbox. For instance, you can lower your stack size hard limit to 1000 by running:\r
23\r
24{{{ulimit -Hs 1000}}}\r
25\r
26= How Draconian! Why do we have these limits?? =\r
27\r
28On our old server, we had multiple instances of users running benign yet out-of-control processes that ended up allocating all available memory. Shared daemons, like our web and mail servers, would then crash when trying to allocate memory, creating denial-of-service for everyone. The ssh daemon wasn't even able to work properly without available memory, so we sometimes needed to ask the techs at our hosting facility to reboot the server for us! It's always better safe than sorry when it comes to protecting users from breaking other users' services.\r