Is it normal for PID's to be over 65535?

I have a managed VPS running on CloudLinux 6.6 x86_64 standard.

It has a few websites with MySQL, PHP and Apache running with CPanel.

I am working on a PHP system that needs to manage a PID and detect it's status.

I have defined an smallint field (2 bytes) on my MySQL database to store the PID.

But today, I noticed something weird:

The service was "acting up" and saying that the process wasn't running when in fact the task finished.

I looked it up and there were processes with PID's as high as 997282 (highest so far).

I tried to look this over on Google and nothing that helps me.

I only found informations about the file /proc/sys/kernel/pid_max which I used to read it and get the maximum PID from there, which is 1048576.

Is this normal to have PID's over 65535?

Kind of unrelated: Is the server screaming for a reboot when the PID's get above 10000?

Any additional information you might need, I am willing to provide to a certain point where no secret is revealed.


PIDs are recycled. When a process exits its PID can be used later by another process, so you don't "run out" or need to reboot simply because a PID near the maximum value exists But see below...

I don't modify this sysctl parameter unless it's necessary; e.g. working on a busy system withe lots of short-lived processes or a heavily multithreaded application with long-running processes.

Usually I set to 99999 or in some cases, 999999...

In one notable case, I had a database server that ran out of process IDs. PIDs were being exhausted by an average of 9,000-10,000 concurrent database connections. Each spawned several threads, hitting the 32,768 limit configured in the OS. This raised the system load average because of the high run queue.

Raising the PID maximum value relieved the pressure.

Edit:

If this is a VPS, I think the host would have a high pid_max value because the PIDs are shared amongst the guests on the system. It's probably to provide headroom.


The theoretical maximum pid number of 32 bit systems is 32768 and for 64 bit systems 4194304. You can define another cap that is below this numbers in the file you mentioned in your question (/proc/sys/kernel/pid_max).

If the pid_max is reached (by running processes) the system doesn't allow new processes to be created until existing ones exit and get cleaned up. So you have no problem unless your system has 1048576 running processes.