When a non-website service is added to Anti-DDoS Proxy, load balancing may distribute requests from the same client across different backend servers, causing login timeouts or unexpected disconnections. Session persistence routes all requests from the same source IP address to the same backend server for a specified duration, maintaining session continuity.
Limitations
Session persistence is incompatible with Application-layer Protection. You cannot enable session persistence on a port forwarding rule that has Application-layer Protection turned on.
If Application-layer Protection is enabled after session persistence is configured, the session persistence configuration is retained but stops working.
Prerequisites
Before you begin, ensure that you have:
A non-website service added to Anti-DDoS Proxy. For more information, see Manage forwarding rules
Configure session persistence for a single port
Log on to the Anti-DDoS Proxy console.
In the top navigation bar, select the region of your instance.
Chinese Mainland: Select this option for Anti-DDoS Proxy (Chinese Mainland) instances.
Outside Chinese Mainland: Select this option for Anti-DDoS Proxy (Outside Chinese Mainland) instances.
In the left-side navigation pane, choose Provisioning > Port Config.
Select the instance, find the forwarding rule you want to manage, and click Session Persistence under Configure.
Enable Session Persistence, set the Timeout Period in seconds (30–3600), and click OK.
The Session Persistence status changes to Enabled.
Configure session persistence and health checks for multiple port forwarding rules
Use batch operations to configure session persistence and health checks across multiple port forwarding rules at once.
Log on to the Anti-DDoS Proxy console.
In the top navigation bar, select the region of your instance.
Chinese Mainland: Select this option for Anti-DDoS Proxy (Chinese Mainland) instances.
Outside Chinese Mainland: Select this option for Anti-DDoS Proxy (Outside Chinese Mainland) instances.
In the left-side navigation pane, choose Provisioning > Port Config.
Select the instance and choose Batch Operations > Add Session and Health Check Settings.
In the Add Session and Health Check Settings dialog box, enter the required information as shown in the sample file and click OK.
Note: To edit existing settings, export them to a TXT file first, modify the file, then copy and paste the content back into the dialog box. For more information, see Export configurations of multiple websites.
Batch configuration format
Each line represents one forwarding rule. Fields are separated by spaces, in the following order:
| Position | Field | Description |
|---|---|---|
| 1 | Forwarding port | Must match a port defined in your existing port forwarding rules |
| 2 | Forwarding protocol | TCP, HTTP, or UDP |
| 3 | Session persistence timeout | Seconds; valid range: 30–3600 |
| 4 | Health check type | Type of health check to perform |
| 5 | Port | Health check port |
| 6 | Response timeout | Health check response timeout |
| 7 | Check interval | Interval between health checks |
| 8 | Unhealthy threshold | Number of failures before marking a server unhealthy |
| 9 | Healthy threshold | Number of successes before marking a server healthy |
| 10 | Health check path | Required for HTTP health checks |
| 11 | Domain name | Optional; applies to HTTP health checks only |
Health check recommendations by protocol:
UDP rules: Configure a UDP health check.
TCP rules: Configure a TCP health check (Layer 4) or an HTTP health check (Layer 7).
HTTP health check: Health check path is required. Domain name is optional.