Azure Service Bus代理连接(Brokered connection)计费计数规则咨询
Great question—this is such a common point of confusion when switching from RabbitMQ to Azure Service Bus, since their connection models work quite differently. Let me break this down clearly for your setup:
Core Rule for Brokered Connection Count
A single application process running on one machine will count as one brokered connection, no matter how many queues or topic subscriptions it listens to or sends messages to—as long as you’re using the modern Azure Service Bus SDK and reusing a single ServiceBusClient instance across all your queue/subscription clients.
Why This Works
Brokered connections are persistent TCP links between your app and the Azure Service Bus namespace. The modern SDK (like the Azure.Messaging.ServiceBus NuGet package) uses a connection pooling system:
- When you create one
ServiceBusClientwith your namespace connection string, it sets up a small pool of connections (default is 1 per CPU core, configurable) that all your queue receivers/senders share. - Even with 1000+ queues, all the client objects for those queues will reuse connections from this pool—so you won’t get charged for 1000 separate connections.
Applying to Your Scenario
For your setup:
- 12 processing machines + 1 queue-filling machine = 13 total machines
- If each machine runs a single app process that handles all its queues with a shared
ServiceBusClient, you’ll only be charged for 13 brokered connections total—not 1000+.
Critical Mistakes to Avoid
To prevent accidental overcharging:
- Don’t create a separate
ServiceBusClientfor each queue. Each unique client can spin up its own connection pool, which would multiply your connection count. - If you run multiple independent app processes on the same machine (e.g., two separate services), each process counts as a separate brokered connection.
- Connections are counted per namespace—if your app connects to two different Service Bus namespaces, that counts as two separate connections.
Quick Reference Table
| Scenario | Brokered Connection Count |
|---|---|
Single process on 1 machine, 1000 queues (shared ServiceBusClient) | 1 |
| 13 machines, each with 1 process handling 1000 queues | 13 |
| 1 machine, 2 separate processes handling queues | 2 |
内容的提问来源于stack exchange,提问作者Matt Burland

