I ran few performance tests with MQTTNet and got unexpected results Looking for help to see if there are some configuration changes that I missed or there are MQTTNet implementation limitation. Environment: I have 3 processes on one box : Sender -> Server -> Subscriber
Tests:
Messages Sender Server Subscriber Time
100K 1 instance sends 100K messages -> 1 -> 1 instance 30sec
100K (1000*100) 1k instances sends 100 messages -> 1 -> 1 instance 32sec
100k (10000*10) 10K instances sends 10 messages -> 1 -> 1 instance 340sec
I see that moving from 1 instance to 1000 do not significantly impact performance, but moving to 10K senders (1 process with 10k client instances) significantly impact performance.
In last test all messages delivered to server in 50sec and after server sends messages to subscriber. after 50 sec CPU dropped to 25%
Server start
var optionsBuilder = new MqttServerOptionsBuilder()
.WithConnectionBacklog(10000)
.WithDefaultEndpointPort(8883)
.WithDefaultEndpointBoundIPAddress(IPAddress.Parse("xxx"))
.WithApplicationMessageInterceptor(context =>
{
Interlocked.Increment(ref cnt);
}
)
.WithMaxPendingMessagesPerClient(100);
mqttServer = new MqttFactory().CreateMqttServer();
await mqttServer.StartAsync(optionsBuilder.Build());
Client Start
var options = new MqttClientOptionsBuilder()
.WithClientId(name)
.WithTcpServer("xxxx", 8883)
.Build();
var factory = new MqttFactory();
mqttClient = factory.CreateMqttClient();
mqttClient.UseApplicationMessageReceivedHandler(e =>
{
Interlocked.Increment(ref cnt);
});
// for receiver
mqttClient.UseConnectedHandler(async e =>
{
Console.WriteLine("### CONNECTED WITH SERVER ###");
await mqttClient.SubscribeAsync(new TopicFilterBuilder().WithTopic("my/topic").Build());
Console.WriteLine("### SUBSCRIBED ###");
});
MQTTNet version 3.0.11,
OS Windows 10
Why with 10K clients I observe so significant degradation while almost no degradation with 1000 clients. Can I miss some configuration ?