How does L4 Persistence work on a Network vService; how is the duration set?
Short answer
L4 Persistence sends the connections coming from the same client IP to the same Backend Service for a specified duration. On a Network vService, the L4 persistence switch is turned on in the Details → LB Algorithm box (its default value is off) and a duration and unit are entered; when it is turned on, the duration comes as 5 minutes. In WEB-CLI, the --l4Persistence.val and --l4Persistence.unit fields are written together with lb service update. For SIP traffic, there is also SIP Persistence; it works only while L4 persistence is on.
Problem: The Same Client's Connections Go to Different Servers
A Network vService distributes each connection separately according to the algorithm. In protocols where a client opens more than one connection (e.g. control and data channels, IKE and ESP, SIP calls) or in applications that keep session information on the server, the connections must go to the same server. Since a Network vService does not see the packet content, persistence can be established only according to the client IP.
How Does It Work?
- The client's first connection is distributed by the algorithm; TR7 remembers the client IP → Backend Service mapping.
- Within the duration, new connections from the same IP go to the same Backend Service; as long as connections keep coming from the same IP, the mapping is preserved.
- Persistence is per client IP; all users behind a NAT count as a single client.
- The mapping is device-local; in a cluster, if the VIP moves to the peer device, the clients are redistributed there.
- SIP Persistence keeps SIP calls on the same Backend Service according to the call ID (Call-ID); it works only while L4 persistence is on. When Protocol is ANY - L3, the field is hidden, and while Port Range is on, it is not applied (SIP Persistence).
Solution: Two Methods
| Your situation | Suitable method |
|---|---|
| I want to set it from the panel | Method 1: Network vService form |
| I want to set it from the command line | Method 2: WEB-CLI |
Method 1: Network vService Form Recommended
- How it works L4 persistence is turned on and a duration is given; as long as the duration is greater than zero, the same client IP goes to the same Backend Service.
- Where it is openedLoad Balancer → Load Balancer vService List → Network vService → Edit → Details → LB Algorithm box → L4 Persistence
- Requirement None (off by default)
- vService type Network
Step-by-Step Configuration
On the Load Balancer → Load Balancer vService List screen, the Network vService is selected and Edit is clicked.
The Details switch at the top right of the form is turned on and the LB Algorithm box is checked.
The L4 Persistence switch is set to Enabled; the duration comes as 5 minutes. The duration (at least 1) and the unit (seconds, minutes, hours) are set to the desired value.
For SIP traffic, SIP Persistence is turned on (its default value is off). UDP packets that cannot be parsed as SIP are dropped; therefore, it is turned on only in vServices that carry SIP over UDP.
Save is clicked (Save). On a Network vService, the save is applied by restarting the service; the change is made at a time when traffic is low. While Clustering is on and Manual Sync Mode is off (default), the setting is transferred to the peer device automatically.
To remove persistence, the L4 Persistence switch is set to Disabled in the same box and saved with Save.
Verification
On the Left Monitor Panel → vService → Logs & Tracking → vService Sessions screen, the Destination IP column of the connections of the same Client IP is compared.
Same Client IP → same Destination IPMethod 2: WEB-CLI
- How it works The L4 persistence duration is written as a value and a unit.
- Where it is opened TR7 WEB-CLI →
lb service update - Requirement WEB-CLI access
- vService type Network
Step-by-Step Configuration
The Layer4 fields are used; the vService ID is written in place of <vService> (Tab lists them). The value and the unit (s, m, h) are written together:
lb service update id <vService> --l4Persistence.val 5 --l4Persistence.unit mlb service update id <vService> --l4SipPersistence trueIf the duration is written as 0, persistence is not applied:
lb service update id <vService> --l4Persistence.val 0Verification
The L4 persistence value and unit are checked in the lb service show <vService> output.
L4 persistence 5 minutesCommon Mistakes
- Not writing the unit in WEB-CLI. If
--l4Persistence.unitis not given, the value is interpreted with the previous unit in the record, or as seconds if there is no previous unit either; the unit is always written explicitly. - Expecting balanced distribution for clients behind a NAT. Persistence is per IP; all users coming from the same IP go to the same server.
- Keeping the duration longer than necessary. A long duration disrupts the distribution among the servers and delays a newly added server from receiving traffic.
- Saving at a busy hour. On a Network vService, the save is applied by restarting the service; the change is made at a time when traffic is low.
- Turning on SIP persistence for non-SIP traffic. UDP packets that cannot be parsed as SIP are dropped.
How it is done in the documentation
