Reactive Client vs Aysnc vs Blocking

Hi,

I can see that HIVE offer three different flavours of their MQTT clients. Has there be any bench marking done for each client? For example how many messages can they subscribe to, how many can each publish?

In terms of subscribing, will need to subscribe, consume and process about 3.5k messages a minute. So a lot of throughput.

I was gonna use the reactor flavour, but reactive programming can be bit difficult to work with at times, and was thinking more of using the blocking client. Will blocking be too slow? The app is wrote using Spring Boot also

Hi there, @Barycat55

A warm welcome to the HiveMQ Community! We’re excited that you’re interested in MQTT and the HiveMQ broker. Your presence adds value to our community.

It’s great that you’re considering HIVE MQTT clients for your project! While there isn’t a specific benchmark available for each client, I can provide you with some general insights and considerations that might help you make your decision.

Firstly, in terms of subscribing and processing around 3.5k messages per minute, the choice between the reactive and blocking client depends on your specific use case and preferences. The “reactor” client is based on reactive programming, which can be very efficient for handling high-throughput scenarios, but it might require a bit more familiarity with reactive programming concepts.

It’s important to note that your choice of client should also align with your existing technology stack. Since you mentioned that your application is built using Spring Boot, you might find it easier to integrate the reactive client into your existing Spring Boot application if you’re already using reactive programming features.

In terms of performance, asynchronous clients (like the “reactor” client) tend to offer better throughput and responsiveness compared to blocking clients because they can efficiently handle multiple concurrent operations. If high throughput is a critical requirement for your application, you may want to lean towards the asynchronous approach.

As for benchmarks, HIVE MQTT clients may not have specific benchmarks available for different scenarios because performance can vary significantly depending on factors like network conditions, hardware, and how you configure and use the clients. Therefore, it’s often recommended to conduct your own performance testing and profiling to determine which client suits your needs best in your unique environment.

You can find example clients and usage scenarios in the HiveMQ MQTT client’s GitHub repository at the following link: https://github.com/hivemq/hivemq-mqtt-client/tree/master/examples/src/main/java/com/hivemq/client/mqtt/examples. These examples can be a valuable resource to understand how each client is used and to kickstart your integration process.

In conclusion, your choice between the “reactor” and “blocking” client should be based on your familiarity with reactive programming, your application’s existing technology stack, and your specific performance requirements. Regardless of which client you choose, proper configuration and testing in your unique environment will be essential to ensure it meets your throughput goals.

If you have any more specific questions or need further assistance with your decision, feel free to ask. Good luck with your project!

Best regards,
Dasha from HiveMQ Team

Hi Dasha,

Thanks for the reply. Yeah think reactor is the way to go.

Am I able to use the reactor MQTT client with non reactive java code? Or does the whole application have to be reactive to fully leverage the whole features?

Hi @Barycat55

Certainly you can use the Reactor MQTT client with non-reactive Java code, and your entire application doesn’t have to be reactive to take advantage of its features. The Reactor MQTT client provides both reactive and non-reactive APIs, allowing you to choose the one that fits your application’s architecture and requirements.

Here are some resources that can help you understand how to switch between the HiveMQ MQTT Client LIbrary flavors:

Blog Articles:

  1. The HiveMQ MQTT Client Library for Java and Its Blocking API Flavor
  2. The HiveMQ MQTT Client Library for Java and Its Async API Flavor
  3. The HiveMQ MQTT Client Library for Java and Its reactive API Flavor

Examples:

  1. Mqtt5Features.java
  2. RequestResponse.java

If you have any more questions or need further assistance, feel free to ask!

Regards,
Dasha from HiveMQ Team