Service Bus Backplane for high scaleability
Are there any efforts underway or does there already exist an Azure Service Bus backplane such that I can scale out multiple instances of MQTTNet servers? Something similar to the SignalR backplane here: https://docs.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-with-windows-azure-service-bus.
Hi, sorry but such a solution does not exist. Best regards Christian
Thanks.
Any ideas or recommendations on how one might want to scale this thing out?
On Thu, May 10, 2018 at 1:59 PM, Christian [email protected] wrote:
Hi, sorry but such a solution does not exist. Best regards Christian
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chkr1011/MQTTnet/issues/254#issuecomment-388133850, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBEEaXTOSDqRkqk36J1zzu8kyRb0wxwks5txH_tgaJpZM4T5S19 .
A key decision is to figure out how you would partition data. A naive example: if you were building a Slack clone, I would partition based on company ID as user form company A never sends message to a user from Company B in slack. If a user is part of two different companies, they login separately to each company in Slack, and for all intents and purposes those are two entirely independent users and connections.
- Choose your partitionKey, say CompanyID, and each topic should include the patititonKey, say:
companyid/6/users/56/etc.. - write a function that processes the partitionkey to return a server. For example you have two servers online, odd CompanyID connect to server1, even CompanyID connect to server2.
- Put this function into a HTTPserver, and make it return the URI of MQTT server.
- Before connecting, each MQTT client asks this server where it should connect Bam! You are scaling with almost no code written specifically for scaling.
Ofcourse there are cases where this wouldn't work, but that's probably all the advise I can give. 🚚
@djarvis - I'm not sure if you're trying to scale the server or the client in your example, but we ran into this same issue.
We put emqtt.io on the server side, as it supports clustering / node based deployment by default, and wrote some custom code to throw it into an azure cloud service. We can scale it up or down and it creates nodes and attaches them automatically.
On the client we use Christians mqtt.net library, and use shared subscriptions. (our client is a web server subscribing to messages coming through the server from sensors...IOT devices).
With the shared subscription model, only 1 web server in the scaled set will handle any given message. We then added a second level of scale-out....we turn around and when the mqtt.net client in the web server process receives a message, it turns around and calls itself at a URL that matches the topic, and the payload becomes the body.
Because it will call back out of the load balancer, any one of the web servers can handle an incoming request.
topic: /mysensor/serialnumber
url : /api/mysensor/{serial number}
public async Task
This ends up working fantastically. We run the MQTT.NET client as a microservice inside an ASP.NET Core 2.1 container, as an IHostedService
Hope that helps