Git Product home page Git Product logo

resrc's Introduction

Systemd user resource limitation imposer

resrc (i.e. Resource Control) imposes arbitrary CGroup resource constraints upon every user session when they are first created. In other words, when a user first logs in, resrc receives a signal and invoke Systemd's API to set constraint over her resource usage.

See here for a list of available resource type.

See examples/config.yaml for example configuration file.

Install

python setup.py install

Develop

# Work in a virtual environment
virtualenv env

# Jump into it.
source env/bin/activate

# In another terminal window, automatically re-install the scripts when they are being modified
\ls bin/* lib/*.py | entr -s 'python setup.py develop' 

Package

ArchLinux

makepkg

Example (rules read from commandline)

Apply the MemoryMax Systemd resource rule to the user john:

$ resrctl --users john --rules MemoryMax=53687091200 # 50 GiB in bytes

Apply the MemoryMax (in percentage) resource limit to users alice and `bob:

$ resrctl --users alice,bob --rules MemoryMax=40% # 40% of RAM

Apply the MemoryMax (in percentage) resource limit to users alice and bob:

$ resrctl --users alice,bob --rules MemoryMax=40% # 40% of RAM

Apply the CPUQuota (in percentage) resource limit to users doge and meow and all users in group faculty and student:

$ resrctl --users doge,meow --groups faculty,student --rules CPUQuota=40% # 0.4 vCPU

Apply the CPUQuotaOverall (in percentage) resource limit to user doge:

# If the system has 8 vCPU, doge will get 8*0.2 = 1.6 vCPU
$ resrctl --users doge --rules CPUQuotaOverall=20%

Example (rules read from configuration file)

$ resrctl --config examples/config.yaml

resrc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wheatdog

resrc's Issues

Apply resource constraints to existing user session

The current implementation only attach CGroup resource constraints to new user session.
Still need to attach the same constraints to user session already present when resrc starts.

Specifically, invoke the DBUS endpoint org.freedesktop.systemd1.Manager.ListUnits defined in here, extract user sessions and apply constraints over them.

Add necessary files for creating a package

Let's start with packaging for ArchLinux.

  1. Need a configuration file template, a Systemd service file for running resrctl
  2. Update the build steps in PKGBUILD.

P.S. I think we can move files related to packaging to a new subdirectory pkg.
Support for other distribution welcomed.

Support config live-reload

It will be useful if this tool can automatically reload config and apply updated rules. Maybe need to implement #1 first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.