# Weight calculation for load balancing

This calculation shows how to choose an appropriate weight for each active gateway when you use load balancing.

When using two or more active gateways, choosing the appropriate weight for each gateway can be difficult. This calculation shows how traffic distribution matches up with the weight assigned to each link.

The calculation uses these abbreviations:

• w1 = weight for link 1.
• w2 = weight for link 2.
• pt = proportional traffic percentage.
• pt1 = traffic percentage for link 1.
• pt2 = traffic percentage for link 2.

First you need to calculate the proportional traffic percentage:

``pt = 100 / (w1 + w2)``

Next you calculate the singular percentage for the two links:

``````pt1 = w1 x pt
pt2 = w2 x pt``````

For example, if w1 = 1 and w2 = 2, the calculation becomes:

``pt = 100 / (1+2) = 100/3 = 33.3``

This means that the traffic percentage is:

``````pt1 = 1 x 33.3 => 33%
pt2 = 2 x 33.3 => 66%``````

If you change the weight it changes the traffic percentage.

For more than two links, you can sum the weight of all the links using the formula:

``pt = 100 / ( w1 + w2 + ... + wn)``

The traffic is routed to the gateway as per the number of sessions and not the data from each session.

For example:

• Session 1 is media streaming: 200 MB data used.
• Session 2 is website browsing: 150 KB data used.
• Session 3 is an FTP connection: 200 KB data used.

If gateway 1 has a weight of 2 and gateway 2 has a weight of 2, then session 1 and session 2 go through gateway 1 and session 3 goes through gateway 2.