Inlab Networks : BalanceNG: Example 9 (Location-Based Load Balancing)
BalanceNG
About/Features
Datasheet
References
Download
Documentation
Examples
   - Example 1
   - Example 2
   - Example 3
   - Example 4
   - Example 5
   - Example 6
   - Example 7
   - Example 8
   - Example 9
   - Example 10
   - Example 11
   - Example 12
   - Example 13
   - Example 14
   - Example 15
   - Example 16
   - Example 17
   - Example 18
   - Example 4-1
FAQ
Tips+Tricks
Configs
Pricing+Order
License Shop
Key Factory
Support
Change History
Benchmarks
PartnerNetwork
OEM Systems
BNG V4 FRs
RBridge
Balance
Inlab-Scheme
 
BalanceNG - The Software Load Balancer
BalanceNG®

The Software Load Balancer and Embeddable ADC

10 Years BalanceNG

BalanceNG certified system
Thomas-Krenn LES LoadBalancer
certified OEM Load-Balancers

 

Location-Based Load Balancing (IPDB/LGRP)


Figure 1: Network Setup

Overview

This example is similar to example 5, but introduces the following new key concepts available with BalanceNG 2.160 and higher:

  • Location-Based Load Balancing with the IPDB IP-to-location database
  • Grouping of targets using "Location Groups" (LGRP)

New Concepts and Configuration Directives

First of all it's needed to load a IP-to-Location database file into memory. This is done with the "ipdb" command loading the file from the default location:

ipdb      "/opt/BalanceNG/ip-to-country.csv"

BalanceNG supports the following two different .csv database file formats (without any warranty and under the licensing terms of the original maintainers):

Then, two "location groups" are defined: Group A containing the coutries Germany, Austria and Switzerland and Group B containing everything else (including client IP addresses which are not found in the database). This is done by including the following lines in the BalanceNG configuration:

lgrp      {
          A "DE,AT,CH"
          B "*,!A"
}

The server section needs to have "ipdb enable" included to enable the IPDB lookup mechanism like this:

server    1 {
          ipaddr 172.16.1.10 
          targets 1,2,3,4
          port 80,443
	  protocol tcp
          ipdb enable
	  method agent
}

Please note that the ipdb lgrp feature does not work with the server methods "rr" (round-robin) and "hash".

As a final step the targets need to be associated with the "location groups" defined earlier in the configuration file. This is done by including the directive "lgrp" in the target section. In this example target 1 and two are member of lgrp A, and target 3 and 4 are member of lgrp B:

target    1 {
          ipaddr 172.16.1.100
          lgrp A
	  agent 439,2,5
	  script "/usr/lib/mon/mon.d/http.monitor -p $port$ -u /index.html $ipaddr$",2,7
          dsr enable
}
target    2 {
          ipaddr 172.16.1.101 
          lgrp A
          agent 439,2,5
	  script "/usr/lib/mon/mon.d/http.monitor -p $port$ -u /index.html $ipaddr$",2,7
          dsr enable
}
target    3 {
          ipaddr 172.16.1.102
          lgrp B
	  agent 439,2,5
	  script "/usr/lib/mon/mon.d/http.monitor -p $port$ -u /index.html $ipaddr$",2,7
          dsr enable
}
target    4 {
          ipaddr 172.16.1.103 
          lgrp B
          agent 439,2,5
	  script "/usr/lib/mon/mon.d/http.monitor -p $port$ -u /index.html $ipaddr$",2,7
          dsr enable
}

Informational Commands

The command "show ipdb" displays information about the currently loaded IP-to-location database:

NodeA# show ipdb
  IPDB loaded from /opt/BalanceNG/ip-to-country.csv
  83429 valid 5-column lines
  83429 total IPDB entries available
  no consecutive area overlaps
  235 different IPDB locations referenced
NodeA#

Another interesting feature is the ability to "locate" any IPv4 address using the locate command like this:

NodeA# locate 82.135.110.2
  address 82.135.110.2 is in DE (GERMANY)
NodeA#

The command "show locations" displays an overview of the current known locations in the IPDB database. Additionally, there's a session counter maintained for each location (example output truncated):

NodeA# sh locations
  key  counter description
  --- -------- ------------------------------------
   AD          ANDORRA
   AE        2 UNITED ARAB EMIRATES
   AF          AFGHANISTAN
   ...
   CN       44 CHINA
   CO        9 COLOMBIA
   CR          COSTA RICA
   CS        4 SERBIA AND MONTENEGRO
   CU          CUBA
   CV          CAPE VERDE
   CY        2 CYPRUS
   CZ        9 CZECH REPUBLIC
   DE      596 GERMANY
   DJ          DJIBOUTI
   DK       23 DENMARK
   DM          DOMINICA
   DO        8 DOMINICAN REPUBLIC
   ...
   UM          UNITED STATES MINOR OUTLYING ISLANDS
   US      708 UNITED STATES
   UY        3 URUGUAY
   UZ        1 UZBEKISTAN
   VA          HOLY SEE (VATICAN CITY STATE)
   VC          SAINT VINCENT AND THE GRENADINES
   VE        8 VENEZUELA
   VG          VIRGIN ISLANDS, BRITISH
   VI          VIRGIN ISLANDS, U.S.
   VN       23 VIET NAM
   VU          VANUATU
   WF          WALLIS AND FUTUNA
   WS          SAMOA
   YE          YEMEN
   YT          MAYOTTE
   ZA          SOUTH AFRICA
   ZM          ZAMBIA
   ZW          ZIMBABWE
   -        30 *** NOT FOUND PSEUDO ENTRY ***
  --- -------- ------------------------------------
  235     2940 total

Some descriptions appear to be empty in the database from WebHosting.info (which is accepted by BalanceNG). The command "clear locationcounters" resets all these counters back to 0.

Configuration Files

The configuration files in this example are complete and are meant to be a reference ready for production use.

Please contact us in case of any questions, errors or suggestions at info@inlab.de.


Copyright © 1991-2016,2017 by Inlab Networks GmbH, All Rights Reserved - Impressum - Datenschutzerklärung - Widerrufsrecht - Sitemap - Internal