Since your tags have centos, you can use systemd.
For example if you want to limit user with ID of 1234:
sudo systemctl edit --force user-1234.slice
Then type and save this:
[Slice]
CPUQuota=10%
Next time that user logs in, it will affect.
Man pages: systemctl, systemd.slice, systemd.resource-control...