Inter-process communication
프로세스 간 통신(Inter-Process Communication, IPC)이란 프로세스들 사이에 서로 데이터를 주고받는 행위 또는 그에 대한 방법이나 경로를 뜻한다.
주요 IPC 방식
방식 | 운영 체제 및 기타 환경이 제공 |
컴퓨터 파일 | 대부분의 운영 체제 |
유닉스 신호 | 대부분의 운영 체제. 윈도와 같은 일부 시스템은 C 런타임 라이브러리에서만 신호를 제공하며 IPC 방식으로 사용하는 것을 지원하지는 않는다. |
네트워크 소켓 | 대부분의 운영 체제 |
메시지 큐 | 대부분의 운영 체제 |
파이프 (유닉스) | 모든 POSIX 시스템, 윈도 |
모든 POSIX 시스템, 윈도 | |
모든 POSIX 시스템, 윈도 | |
모든 POSIX 시스템, 윈도 | |
메시지 전달 | 메시지 전달 인터페이스(MPI) 패러다임, Java RMI, CORBA, 마이크로소프트 메시지 쿼링 (MSMQ), 메일슬롯, QNX 등에 쓰임 |
메모리 맵 파일 | 모든 POSIX 시스템, 윈도 |
IPC 성능 비교
- Github - IPC benchmark on Linux
- Pipe vs Unix Socket Performance - wiki.openlighting.org
- linux - IPC performance: Named Pipe vs Socket - Stack Overflow
- goldsborough/ipc-bench - Benchmarks for Inter-Process-Communication Techniques
- IPC Performance Comparison: Anonymous Pipes, Named Pipes, Unix Sockets, and TCP Sockets | Baeldung on Linux - 중요한건 전송하려는 패킷의 크기 이다.
순차 처리량을 측정하기 위해 우리는 두 프로세스 간에 단일 메시지를 앞뒤로(즉, 핑퐁) 보냅니다.
Method | 100 Byte Messages | 1 Kilo Byte Messages |
Unix Signals | --broken-- | --broken-- |
ZeroMQ (TCP) | 24,901 msg/s | 22,679 msg/s |
Internet sockets (TCP) | 70,221 msg/s | 67,901 msg/s |
Domain sockets | 130,372 msg/s | 127,582 msg/s |
Pipes | 162,441 msg/s | 155,404 msg/s |
Message Queues | 232,253 msg/s | 213,796 msg/s |
FIFOs (named pipes) | 265,823 msg/s | 254,880 msg/s |
Shared Memory | 4,702,557 msg/s | 1,659,291 msg/s |
Memory-Mapped Files | 5,338,860 msg/s | 1,701,759 msg/s |
Benchmarked on Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz running Ubuntu 20.04.1 LTS.
NOTE: The code is rather old and there might be sub-optimal configurations! We are happy to update the configuration with concrete suggestions (see contributions below). In particular, zeromq is a great library and should probably be performing better, especially because we are only using the TCP implementation. There is one dedicated for IPC (-> TODO). In addition, there is little technical reason for shared memory to perform differently than memory-mapped files (could be due to a lack of warmup). Non-the-less, hopefully, this benchmark can serve as a solid starting point by providing ball-park numbers and a reference implementation.
노드 간 통신에 대한 자세한 평가는 L5 라이브러리를 참조하십시오.
Unix Domain Sockets 와 Named PIPE 의 성능 차이는 PC/OS 마다 차이 있는듯.
TCP/IP vs Unix Domain Sockets vs Named PIPE
Unix Domain Socket#TCP/IP vs Unix Domain Sockets vs Named PIPE 항목 참조.
Shared Memory 과 일반 스레드 메모리 의 성능 차이
초기 Page 생성시만 다르고 나머지는 비슷
Posix shared memory vs mapped files
구별이 항상 명확한 것은 아닙니다. 공유 메모리는 메모리 매핑 파일을 통해 구현될 수 있습니다.
관련글: Memory Mapped Files And Shared Memory For C++
- std::memory_mappable
- std::mapped_region
표준 입출력 Pipe 속도 테스트
dd명령을 사용한 방법은 Standard streams#표준 입출력 Pipe 속도 테스트 항목 참조.