Skip to content

Commit 9146177

Browse files
authored
Add traffic control rule for web pubsub
1 parent d67f81a commit 9146177

File tree

1 file changed

+40
-14
lines changed

1 file changed

+40
-14
lines changed

articles/azure-web-pubsub/howto-configure-application-firewall.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The Application Firewall provides sophisticated control over client connections
1717

1818
## What Does the Application Firewall Do?
1919

20-
The Application Firewall consists of various rule lists. Currently, there is a rule list called *Client Connection Count Rules*. Future updates will support more rule lists to control aspects like connection lifetime and message throughput.
20+
The Application Firewall consists of various rule lists. Currently, there are two rule lists called *Client Connection Count Rules* and *Client Traffic Control Rules*. Future updates will support more rule lists to control aspects such as connection lifetime.
2121

2222
This guideline is divided into three parts:
2323
1. Introduction to different application firewall rules.
@@ -48,6 +48,14 @@ Client Connection Count Rules restrict concurrent client connections. When a cli
4848
> * **Avoid using too aggressive maxCount**. Client connections may close without completing the TCP handshake. SignalR service can't detect those "half-closed" connections immediately. The connection is taken as active until the heartbeat failure. Therefore, aggressive throttling strategies might unexpectedly throttle clients. A smoother approach is to **leave some buffer** for the connection count, for example: double the *maxCount*.
4949
5050

51+
## Client Traffic Control Rules
52+
Client Traffic Control Rules restrict the inbound throughput of client connections. When a client attempts to send a message, the rules are checked **sequentially**. Within each *aggregation window*, the message size will be aggregated to check against *max inbound message*. If any rule is violated, the connection is disconnected.
53+
54+
#### TrafficThrottleByUserIdRule
55+
This rule limits the inbound throughput of a user.
56+
57+
#### TrafficThrottleByJwtSignatureRule
58+
This rule limits the inbound throughput of each token.
5159

5260
## Set up Application Firewall
5361

@@ -64,22 +72,40 @@ Use Visual Studio Code or your favorite editor to create a file with the followi
6472
@description('The name for your Web PubSub service')
6573
param resourceName string = 'contoso'
6674
67-
resource webpubsub 'Microsoft.SignalRService/webpubsub@2024-04-01-preview' = {
75+
resource webpubsub 'Microsoft.SignalRService/webpubsub@2024-10-01-preview' = {
6876
name: resourceName
6977
properties: {
7078
applicationFirewall:{
71-
clientConnectionCountRules:[
72-
// Add or remove rules as needed
73-
{
74-
// This rule will be skipped if no userId is set
75-
type: 'ThrottleByUserIdRule'
76-
maxCount: 5
77-
}
78-
{
79-
type: 'ThrottleByJwtSignatureRule'
80-
maxCount: 10
81-
}
82-
]
79+
clientConnectionCountRules: [
80+
// Add or remove rules as needed
81+
{
82+
// This rule will be skipped if no userId is set
83+
type: 'ThrottleByUserIdRule'
84+
maxCount: 5
85+
}
86+
{
87+
type: 'ThrottleByJwtSignatureRule'
88+
maxCount: 10
89+
}
90+
]
91+
clientTrafficControlRules:[
92+
// Add or remove rules as needed
93+
{
94+
// This rule will be skipped if no userId is set
95+
type: 'TrafficThrottleByUserIdRule'
96+
// Every minute
97+
aggregationWindowInSeconds: 60
98+
// 10MB
99+
maxInboundMessageBytes: 10485760
100+
}
101+
{
102+
type: 'TrafficThrottleByJwtSignatureRule'
103+
// Every 30 seconds
104+
aggregationWindowInSeconds: 30
105+
// 5MB
106+
maxInboundMessageBytes: 5242880
107+
}
108+
]
83109
}
84110
}
85111
}

0 commit comments

Comments
 (0)