user2123079
user2123079

Reputation: 686

How to choose zmq maximum buffer size properly?

According to ZMQ-manual

The ZMQ_SNDBUF option shall retrieve the underlying kernel transmit buffer size for the specified socket. A value of zero means that the OS default is in effect. For details refer to your operating system documentation for the SO_SNDBUF socket option.

How can I get it in a simple crossplatform way? Or is the only way to get it somehow like this:

#ifdef _WIN32
some_win_actions
#else
some_other_actions
#endif

And another part of the question: if for example my OS default SO_SNDBUF will be 10, and client's OS SO_SNDBUF will be 5, will it lead to errors, or ZMQ will handle it somehow on client side?

Upvotes: 0

Views: 1917

Answers (1)

user3666197
user3666197

Reputation: 1

Inital note: ZeroMQ buffers and High-watermark(s) for cross-platform code

Well besides both of your original questions, there is one more to be aware of. Buffers and High-Watermark mechanics may be different due to different versions of ZeroMQ-libraries.

For example: a Unix-based grid-computing service uses the most recent ZeroMQ version both in C++ and in python-service components.

This service is open for client-side connections, where no version-control may be responsible for keeping versions update(s). So the resulting scene will have to handle both recent ZeroMQ-connections ( where the Buffers and High-Watermarks' mechanics will match on both sides ) but there is also a vast group of users, who do not or even cannot ( some cross-platform issues in DLL-based wrappers et al ) so simply update the underlying ZeroMQ-version. Their buffers will have other High-Watermark behaviour and your side cannot do a single step to change it in any direction you would wish to.

Q: ...will ZMQ handle it somehow on client side?

Definitely not. ZeroMQ is a very powerful tool, however there is a strict minimalistic design, which avoids any remote-side intervention, if your own code does not create some means for doing that.

Cross-platform solution

There shall be some other logic on these grounds -- setup your code-design, so that it does not devastate your resources ( Buffers / High-Watermarks ).

Simply turn the goal upside down. Design the software so as to live within a maximum proximity towards the Zero-* imperatives (using minimum reasonable amounts of resources), rather than to rely on maximum values (that are out of your control - code-wise and version-wise ).

This way your code shall not suffer from actual values thereof. The code is under your control, not the inner-mechanics or the buffer-constraints given from the operating system.

With this approach your code will be cross-platform and also version-proof.

Upvotes: 2

Related Questions