In the project, often encounter on-machine communication between processes, commonly used inter-process communication methods generally have the following
1 socket
2 Unixsocket
3 Shared Memory (share-memory)
4 Piping (pipe)
5 Message Queuing (message-queue)
6 Files (file)
7 message bus (e.g. ZEROMQ)
8 other middleware (such as Redis, Memchache, database, etc.)
If the project is simply a message delivery, the performance requirements are not high, then each of these methods can achieve interprocess communication, we can choose a more easily implemented way to apply.
If the project has a high demand for messaging performance, then we may choose Unixsocket,file, or sockets, which are the quickest and best performing, and may not be very clear.
Therefore, recently, for the project needs high-performance inter-process communication requirements, several modes of communication performance comparison, the conclusion is as follows:
Performance synthesis sorting results (from good to Bad)
1 |
Zmq |
|
2 |
File (no flush) |
3 |
Msgqueue |
|
4 |
Unixsocket |
5 |
Pipe |
|
6 |
Socket |
|
7 |
File (flush) |
8 |
Share-memory |
The test method is: Send a certain amount of data from the server side, the client receives, the final comparison is total time consuming, and calculates the number of records that can be processed per second.
The specific performance data is as follows:
Write:
How to compare inter-process communication IPC in Linux performance comparison