The current business needs to implement a function of real-time analysis of data flow, which needs to be accurate to the second level. I originally planned to use swoole task to implement a task service, but there is currently no corresponding machine to run the server, so I temporarily decided to use swoole's multi-process model combination During the implementation of swoole's timer, a parent process was encountered and the memory usage continued to soar. Can you please solve it?
The code logic is to create 6 swoole_processes in the parent process, distribute tasks to the idle child processes through swoole_timer every second, and mark the process as busy. After the child process completes the task, it communicates with the parent process through a pipe. Notify the parent process that the current process is idle. Through communication between father and son, it has an effect similar to "the parent process maintains a pool of child processes". If a process is idle for more than a period of time or exceeds a certain number of processing tasks, the parent process can Notify the process to destroy and start a new child process. The code logic is roughly like this, but the problem encountered is that the memory usage of the parent process is gradually increasing. How can the swoole masters solve it? Is it because the parent process maintains this similar child process pool? Please enlighten me
The current business needs to implement a function of real-time analysis of data flow, which needs to be accurate to the second level. I originally planned to use swoole task to implement a task service, but there is currently no corresponding machine to run the server, so I temporarily decided to use swoole's multi-process model combination During the implementation of swoole's timer, a parent process was encountered and the memory usage continued to soar. Can you please solve it?
The code logic is to create 6 swoole_processes in the parent process, distribute tasks to the idle child processes through swoole_timer every second, and mark the process as busy. After the child process completes the task, it communicates with the parent process through a pipe. Notify the parent process that the current process is idle. Through communication between father and son, it has an effect similar to "the parent process maintains a pool of child processes". If a process is idle for more than a period of time or exceeds a certain number of processing tasks, the parent process can Notify the process to destroy and start a new child process. The code logic is roughly like this, but the problem encountered is that the memory usage of the parent process is gradually increasing. How can the swoole masters solve it? Is it because the parent process maintains this similar child process pool? Please enlighten me
The memory of the parent process leaked, which was caused by some global variable arrays not releasing the memory immediately. Check your code.