Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does it make sense to use zeromq on localhost? or it's better to use shared memory?

Tags:

zeromq

I need to transfer financical data between two process (currently c++ and c#, in future c++ and c++ on Linux). It's live quotes - something like 1 100, 1 100.1, 2 101.2 end so on.). Data has well-defined format. Latency must be low. I'm choosing between zeromq and using shared memory myself. I have couple questions about zeromq:

  • will it be less buggy and easier to use zeromq instead of using shared memory myself?
  • if zeromq latency on localhost is comparable with the latency of shared memory?

I don't need to run my parts on different hosts or something like that. So I have one producer-one consumer pattern on localhost. I'm just not sure if I should use zeromq for such simple scenario, or probably i should just use shared memory and that's it?

like image 932
Oleg Vazhnev Avatar asked Dec 26 '22 04:12

Oleg Vazhnev


2 Answers

Shared memory is nasty and error prone, in my opinion. ZMQ is elegant. I would prefer the ZMQ route always.

If anything, ZMQ will be easier to set up than shared memory - not the other way around.

like image 69
Timothy Shields Avatar answered Apr 30 '23 04:04

Timothy Shields


ZeroMQ could be faster than the shared memory because of its baked in buffering. The messaging patterns also provide a much more flexible way of approaching problems. As always, do your own tests and determine which you prefer.

I would expect the ZeroMQ version to be simpler long term.

like image 39
Joshua Avatar answered Apr 30 '23 05:04

Joshua