I am trying to do IPC between 2 processes on the same Linux box in Ruby, and I need to optimize the solution as far as practicable.
I had begun with a TCPSocket but I see that using UNIXSocket is probably faster, and perhaps does not copy data to kernel buffers.
I have been reading SO threads, and looks like mmap might be interesting to look at. But for mmap I need to a) install mmap gem and b) provide locking since multiple client processes would likely try connect with the server process (both running on same box).
My questions:
- What other options would you recommend?
- How do you recommend locking the memory with ruby mmap?
- How do the numbers, if there's any available, stack up for UNIXSocket versus mmap?