{"action":"created","issue":{"url":"https://api.github.com/repos/flynn/flynn/issues/2590","repository_url":"https://api.github.com/repos/flynn/flynn","labels_url":"https://api.github.com/repos/flynn/flynn/issues/2590/labels{/name}","comments_url":"https://api.github.com/repos/flynn/flynn/issues/2590/comments","events_url":"https://api.github.com/repos/flynn/flynn/issues/2590/events","html_url":"https://github.com/flynn/flynn/pull/2590","id":141681852,"number":2590,"title":"Add CPU limits and resource partitions","user":{"login":"titanous","id":13026,"avatar_url":"https://avatars.githubusercontent.com/u/13026?v=3","gravatar_id":"","url":"https://api.github.com/users/titanous","html_url":"https://github.com/titanous","followers_url":"https://api.github.com/users/titanous/followers","following_url":"https://api.github.com/users/titanous/following{/other_user}","gists_url":"https://api.github.com/users/titanous/gists{/gist_id}","starred_url":"https://api.github.com/users/titanous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titanous/subscriptions","organizations_url":"https://api.github.com/users/titanous/orgs","repos_url":"https://api.github.com/users/titanous/repos","events_url":"https://api.github.com/users/titanous/events{/privacy}","received_events_url":"https://api.github.com/users/titanous/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-17T19:17:43Z","updated_at":"2016-03-18T10:50:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/flynn/flynn/pulls/2590","html_url":"https://github.com/flynn/flynn/pull/2590","diff_url":"https://github.com/flynn/flynn/pull/2590.diff","patch_url":"https://github.com/flynn/flynn/pull/2590.patch"},"body":"### CPU limits\r\n\r\nCPU limits are implemented as a resource denominated in “milliCPUs”, a concept from Google. When doing placement, a request for 1000 milliCPUs will be equivalent to a single CPU core.\r\n\r\nA limit of 1000 milliCPUs results in the Linux default of 1024 CPU shares, and the request portion of the resource spec can be used for scheduling in the future.\r\n\r\nCPU shares are relative, the more shares a process has, the higher priority it is. When a host is under load, a job with 2000 milliCPUs will get twice the CPU time as a job with the default of 1000.\r\n\r\nLimits can be specified on a per-process basis with:\r\n\r\n```text\r\nflynn limit set web cpu=1500\r\n```\r\n\r\n### Resource Partitions\r\n\r\nResource partitions complement CPU limits in order to isolate system apps from user apps. A top-level set of cgroups is added that all jobs are nested under. Currently these cgroups just provide CPU share allocations, but in the future they can be used for any other cgroup control. The partitions are only throttled when all partitions are under equal load, full bursting is allowed, unused shares are given to the other partitions on a proportional basis. With that in mind, the default allocations are:\r\n\r\n- `system`, all Flynn-managed system apps, with 25% of available CPU time\r\n- `user`, all user app processes, with 50% of available CPU time\r\n- `background`, slugbuilder builds, with 25% of available CPU time\r\n\r\nAllocations can be modified by passing the `--partitions` flag to `flynn-host daemon` like this:\r\n\r\n```text\r\nflynn-host daemon --partitions \"system=cpu_shares:4096 background=cpu_shares:4096 user=cpu_shares:8192\"\r\n```"},"comment":{"url":"https://api.github.com/repos/flynn/flynn/issues/comments/198303290","html_url":"https://github.com/flynn/flynn/pull/2590#issuecomment-198303290","issue_url":"https://api.github.com/repos/flynn/flynn/issues/2590","id":198303290,"user":{"login":"josephglanville","id":605591,"avatar_url":"https://avatars.githubusercontent.com/u/605591?v=3","gravatar_id":"","url":"https://api.github.com/users/josephglanville","html_url":"https://github.com/josephglanville","followers_url":"https://api.github.com/users/josephglanville/followers","following_url":"https://api.github.com/users/josephglanville/following{/other_user}","gists_url":"https://api.github.com/users/josephglanville/gists{/gist_id}","starred_url":"https://api.github.com/users/josephglanville/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josephglanville/subscriptions","organizations_url":"https://api.github.com/users/josephglanville/orgs","repos_url":"https://api.github.com/users/josephglanville/repos","events_url":"https://api.github.com/users/josephglanville/events{/privacy}","received_events_url":"https://api.github.com/users/josephglanville/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T10:50:38Z","updated_at":"2016-03-18T10:50:38Z","body":"LGTM"}}