You might need to protect your system against fork bomb attacks.
A simple way to prevent this is by setting up processes limit for your users.
All the limits can be configured in the /etc/security/limits.conf file.
sudo vi /etc/security/limits.conf
This file comes with all the help you need. Here's an example:
user1 hard nproc 100
@group1 hard nproc 20
This will prevent users from a specific group from having a maximum of 20 processes and maximize the number of processes to 100 to user1.