When a query lands on a GSLB service, the load balancing algorithm for GSLB will be applied, and the required number of pool members will be fetched from the specified number of pools. This section explains how to select n pool members from m pools and the DataScript functions to achieve this.

Selecting n Records from m Pools

Consider a scenario in which the GSLB service algorithm was geolocation-based and the distribution of pool members is as follows:

  • US-West-Coast - 4 pools

  • US-East-Coast - 5 pools

  • London - 2 pools

In this scenario, the DNS virtual service assigns the IP addresses of members in the best applicable pool.

A client from the US west coast would receive a member from US-West-Coast. If the number of IP addresses was set to a non-zero value, then the client receives multiple members from US-West-Coast.

However, in some instances, there is a requirement to send multiple IP addresses from various pools. For example, two addresses each from US-West-Coast and US-East-Coast, respectively.

You can select n records from m GSLB pools using the DataScript function avi.gslb.add_records (m,n). With the DataScript attached to the DNS virtual service, it is possible to select m number of pools. From these, n number of members are chosen.


If the pools are of the same priority or in the same geolocation, they will be fetched in round-robin order. To get consistent entries every time, the pools must be configured with unique priorities, and the load-balancing algorithm of the pool members must be a consistent hash.

In addition to this, the following DataScript functions are also supported:




Adds m records to be added from all pools.

If m > the total pool members, all the pool members are returned.

If m = 0 or n = 0, m or n is treated as the maximum available pools or pool members respectively.


Invalid function

Bind the DataScript to the DNS virtual service as shown below:
admin:demo-ctrl]: configure virtualservice *DNS_VS_name*
admin:demo-ctrl]: virtualservice> vs_datascripts index 1 vs_datascript_set_ref *name_of_datascript*
admin:demo-ctrl]: virtualservice>  save