You can do this with cgroups but you aren't allowed to use cgroups if you use systemd, because it messes up systemd.