# Unable To Achieve High Message Throughput

**URL:** <https://community.hivemq.com/t/unable-to-achieve-high-message-throughput/3223>\
**Category:** HiveMQ Client Library\
**Created:** [September 16, 2024, 5:35pm UTC](https://community.hivemq.com/t/unable-to-achieve-high-message-throughput/3223 "2024-09-16T17:35:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helium3](https://avatars.discourse-cdn.com/v4/letter/h/a587f6/32.png) [@Helium3](https://community.hivemq.com/u/Helium3)\
**Post date:** [September 16, 2024, 5:35pm UTC](https://community.hivemq.com/t/unable-to-achieve-high-message-throughput/3223/1 "2024-09-16T17:35:43Z")

</div>

I’m building a system to ingest messages via subscription from an MQTT broker and, in order to test my application, I need to publish messages at volume to the broker. The actual data that I’ll be ingesting is highly structured so I’ve built a java application incorporating the HiveMQ Java Client (async mode) to generate and publish that data. However, I seem to have run into some sort of bottleneck and I’ve more or less run out of avenues to explore to try and figure this out myself. For whatever reason, I’m unable to get above a publish rate of about 250 messages per second (I’d like to get into the range of 10K to 30K messages per second). I’m using instances of Java’s ScheduledExecutorService in parallel to actually manage the send rate and, when I modify this code to not publish to the broker but to simply bump a counter variable up a tick, I’m easily able to achieve this rate. I’m using a Mosquitto for my broker and from what I’ve read online the broker should be easily capable of handling message rates in the range I’m trying to achieve. This leads me to believe that the source of the “bottleneck” is somewhere in the HiveMQ Client Library. Also, at this time, all of this software and infrastructure is running on my local environment.

So, I basically have two questions:

1. Should I be able to achieve the desired message rate (10K to 30K messages per second) using the HiveMQ Java Client Library?
2. Is there some configuration option I’m unaware of (a thread pool size perhaps?) that I need to manage to allow me to achieve the message send rates I want to achieve.

---

<div class="post-metadata">

**Author:** ![Diego](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@Diego](https://community.hivemq.com/u/Diego)\
**Post date:** [September 17, 2024, 2:44pm UTC](https://community.hivemq.com/t/unable-to-achieve-high-message-throughput/3223/2 "2024-09-17T14:44:02Z")

</div>

Hello @Helium3

Welcome to the HiveMQ Community!

Based on the details you’ve provided, handling a publish rate of 30k messages per second with a single MQTT client in a local environment may be challenging, primarily due to limitations in network and processing resources.

While I’m not fully familiar with the throughput capabilities of the Mosquitto broker, I have conducted a simple performance test using [HiveMQ Swarm](https://www.hivemq.com/products/hivemq-swarm/) publish spike scenario and HiveMQ broker on my laptop (via Docker containers). In that scenario, I was able to achieve a publish rate of ˜12k messages per second with a single MQTT client. From my experience, this doesn’t seem to indicate a bottleneck with the HiveMQ Java Client Library itself.

If you’re facing performance challenges, it might be worth investigating your local system’s capacity, Mosquitto broker performance, or exploring parallel publishing strategies.

 ![2024-09-17 at 15.25.40@2x](https://canada1.discourse-cdn.com/flex035/uploads/hivemq1/original/2X/3/3e8ae7445b5c566985e439554f6f21d79ea31863.png)

Kind regards,  
Diego from HiveMQ Team

---

<div class="post-metadata">

**Author:** ![mkbaker](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mkbaker](https://community.hivemq.com/u/mkbaker)\
**Post date:** [September 30, 2024, 5:51pm UTC](https://community.hivemq.com/t/unable-to-achieve-high-message-throughput/3223/3 "2024-09-30T17:51:48Z")

</div>

> [@Diego](#):
>
> parallel publishing strategies.

Can you provide more guidance on “parallel publishing strategies”? I’ve been trying for some time to prevent formation of a bottleneck for message publishing. I have one application that is doing the publishing so I assume I need only one client instance. However, if I start too many asynchronous publishing tasks I either encounter an error (e.g. no packet id) or not all messages are received (despite QoS 1). I’m using the C# client.

I have posted a related issue to the GitHub project|:

> <https://github.com/hivemq/hivemq-mqtt-client-dotnet/issues/201>
>
> \## 🐛 Bug Report
> 
> 
> 
> 
> 
> \## 🔬 How To Reproduce
> 
> Steps to reproduce the behav…ior:
> 
> 1. Compile and run the attached code
> 
> \### Code sample
> 
> See attached code.
> 
> \### Environment
> 
> Where are you running/using this client?
> 
> What version of this client are you using? 0.23.0+build.618
> 
> Operating System? Windows 10
> 
> Hardware or Device? Dell laptop
> 
> .NET version: 6
> 
> \### Screenshots
> 
> Console output:
> 
> Connected result: Success
> Subscribed result: GrantedQoS1 - Notification/HiveRawTest
> Connect: 1 Disconnect: 0 Sent: 50000 Failed send: 0 Unique Received: 5765 Received: 5765 Duplicates: 0 Mismatch: 0
> Connect: 1 Disconnect: 0 Sent: 50000 Failed send: 0 Unique Received: 10756 Received: 10756 Duplicates: 0 Mismatch: 0
> Connect: 1 Disconnect: 0 Sent: 50000 Failed send: 0 Unique Received: 10756 Received: 10756 Duplicates: 0 Mismatch: 0
> 
> 
> \## 📈 Expected behavior
> 
> I am publishing 50,000 messages (on a single topic) as quickly as possible.
> I have a subscription (setup on during connect) that should catch all messages.
> 
> The payload for each message is minimal (4 bytes).
> 
> I receive less than 11,000 message.
> 
> I expected to receive all QoS 1 messages that are published
> 
> If I do not try to publish messages concurrently all messages are (usually) received but it takes much longer.
> 
> \## 📎 Additional context
> 
> 
> \[Program.cs.txt\](https://github.com/user-attachments/files/17194546/Program.cs.txt)
