Kernel-level resource activation for process management
A program executing in kernel space monitors system calls associated with access to an operating system resource. Based on the monitoring, an access attempt to the operating system resource is detected. In response to detecting the access attempt, a process configured to handle the access to the operating system resource is spawned. The process may then terminated based on an expiration of an idle period.
1 . A method, comprising:
monitoring, using a program executing in kernel space, system calls associated with access to an operating system resource;
detecting, based on monitoring the system calls, an access attempt to the operating system resource;
spawning, in response to detecting the access attempt, a process configured to handle the access to the operating system resource, wherein the process configured to handle the access to the operating system resource comprises a PHP FastCGI Process Manager (PHP-FPM) process;
monitoring activity heartbeat signals from the PHP-FPM process to track request processing activity; and
terminating the PHP-FPM process by destroying a PHP-FPM site pool when no heartbeat activity is detected for an idle period.
2 . The method of claim 1 , wherein the program executing in the kernel space comprises an Extended Berkeley Packet Filter (eBPF) program.
3 . The method of claim 1 , wherein the operating system resource comprises a socket and the system calls associated with the access to the socket comprises a connect( ) system call.
4 . The method of claim 3 , wherein the socket is associated with a website in a shared hosting environment.
5 . The method of claim 1 , wherein spawning the process comprises:
spawning the process within an isolated operating system namespace to separate the process from other processes in a computing environment.
6 . The method of claim 1 , wherein detecting the access attempt comprises:
identifying one of the system calls as corresponding to the operating system resource; and
determining that no active process is associated with the operating system resource.
7 . The method of claim 1 , further comprising:
implementing connection retries while the PHP-FPM process is being spawned.
8 . The method of claim 1 , wherein monitoring the system calls comprises:
attaching an Extended Berkeley Packet Filter (eBPF) program to a kernel hook; and
collecting system call data using an eBPF ring buffer.
9 . A device, comprising:
a memory subsystem; and
processing circuitry, the processing circuitry configured to execute instructions stored in the memory subsystem to:
monitor, using a program executing in kernel space, system calls associated with access to an operating system resource;
detect, based on monitoring the system calls, an access attempt to the operating system resource;
spawn, in response to detecting the access attempt, a process configured to handle the access to the operating system resource, wherein the process configured to handle the access to the operating system resource comprises a PHP FastCGI Process Manager (PHP-FPM) process;
monitor activity heartbeat signals from the PHP-FPM process to track request processing activity; and
terminate the PHP-FPM process by destroying a PHP-FPM site pool when no heartbeat activity is detected for an idle period.
10 . The device of claim 9 , wherein, to monitor the system calls, the processing circuitry is further configured to execute instructions stored in the memory subsystem to:
hook into a kernel of an operating system to observe the system calls; and
communicate an occurrence of at least one of the system calls to a controller daemon executing in user space.
11 . The device of claim 10 , wherein the processing circuitry is further configured to execute instructions stored in the memory subsystem such that the controller daemon comprises an Extended Berkeley Packet Filter (eBPF) spawner configured to receive connect events from an eBPF ring buffer and dynamically spawn the PHP-FPM site pools in response to the connect events, wherein the eBPF ring buffer is used to transmit data related to the at least one of the system calls from the kernel space to the controller daemon in the user space.
12 . The device of claim 9 , wherein, to detect the access attempt, the processing circuitry is further configured to execute instructions stored in the memory subsystem to:
identify one of the system calls as corresponding to the operating system resource; and
determine that no active process is associated with the operating system resource.
13 . The device of claim 9 , wherein the operating system resource is one of a plurality of operating system resources, and wherein the processing circuitry is configured to execute the instructions stored in the memory subsystem for each of the plurality of operating system resources in a multi-tenant environment.
14 . The device of claim 9 , wherein, to monitor the system calls, the processing circuitry is further configured to execute instructions stored in the memory subsystem to:
attach an Extended Berkeley Packet Filter (eBPF) program to a kernel hook; and
collect system call data using an eBPF ring buffer.
15 . The device of claim 9 , wherein, to spawn the process, the processing circuitry is further configured to execute instructions stored in the memory subsystem to:
initialize a process configuration based on the operating system resource; and
allocate memory resources for the process within a shared hosting environment.
16 . One or more non-transitory computer-readable storage media comprising instructions that, when executed by one or more processors, perform operations for process management, the operations comprising:
monitoring, using a program executing in kernel space, system calls associated with access to an operating system resource;
detecting, based on monitoring the system calls, an access attempt to the operating system resource;
spawning, in response to detecting the access attempt, a process configured to handle the access to the operating system resource, wherein the process configured to handle the access to the operating system resource comprises a PHP FastCGI Process Manager (PHP-FPM) process;
monitoring activity heartbeat signals from the PHP-FPM process to track request processing activity; and
terminating the PHP-FPM process by destroying a PHP-FPM site pool when no heartbeat activity is detected for an idle period.
17 . The one or more non-transitory computer-readable storage media of claim 16 , the operations further comprising:
queuing subsequent access attempts to the operating system resource during spawning of the process; and
processing the queued access attempts upon completion of the spawning.
18 . The one or more non-transitory computer-readable storage media of claim 16 , the operations further comprising:
receiving an HTTP request at a web server; and
establishing a FastCGI connection from the web server to a PHP FastCGI Process Manager (PHP-FPM) process via the operating system resource.
19 . The one or more non-transitory computer-readable storage media of claim 18 , wherein establishing the FastCGI connection comprises:
implementing connection retries while the PHP-FPM process is being spawned.
20 . The one or more non-transitory computer-readable storage media of claim 16 , wherein detecting the access attempt comprises:
identifying one of the system calls as corresponding to the operating system resource; and
determining that no active process is associated with the operating system resource.