The traditional Java program developer is a strange name. In general, the Java program is mainly used to start a java.exe instead of too many processes. When a single Java program encounters asynchronous design requirements, it usually takes into account the multi-threaded design. However, the main cause of system instability is the multi-threaded design.
In a project I used to participate in, they finished their work when developing the first version of the system, but every time the system was deployed, the system usually ran for three days. Tomcat will cause memory overflow and die. This system memory is unstable and the cause is always found in the entire team for a month. In the end, we find a class in the system module that calls XML to generate images. We find that this function causes memory overflow and JVM cannot recycle the memory of this module well. Because the system needs to analyze more than 10 XML files every three minutes to generate images. In the face of such a situation, the team had no plans at all, and all the solutions could solve the problem at the moment.
Later, I proposed a multi-process method instead of multi-thread plotting. Use an independent process to obtain the data of the specified XML for plotting, and return the drawing result to the specified position. Therefore, the Tomcat memory load can be greatly reduced and the system memory control can be used.
After summing up, I think the multi-process design should be used in the following aspects:
(1) drawing large data volumes;
(2) complex and persistent algorithm analysis;
(3) algorithm compression for large data volumes;
(4) big data analysis;
(5) independent transmission channels;
There are many problems to be faced with the use of multi-process, which are summarized as follows:
(1) multi-process startup (jar, EXE, class, bat );
(2) Multiprocess shutdown;
(3) Dynamic Data Exchange during the process;
(4) process data synchronization, process lock, and process semaphore;
(5) Dynamic Interaction after a process is added to the service;
(6) interaction between processes after cross-origin;
Multi-Process Design flowchart (currently completed functions ):
SVN address of the Process pool:
Http://code.google.com/p/ken-javaframeword/source/browse/#svn%2Ftrunk%2FJavaFramework2.5%2Fsrc%2Fcom%2Fshine%2FMultiProcess
Multiprocess process Pool Design (2) jar process startup and shutdown http://blog.csdn.net/arjick/article/details/7011490
Multiprocess process Pool Design (3) communication between the main process and sub-process
Http://blog.csdn.net/arjick/article/details/7022212