nsx lab – one arm load balancer

Note: this lab is based on VMware HOL 1603

First you need a pair of web servers with apache configured – see here

The goal is a simple one arm balancer to distribute traffic between web-1 and web-2
Note: there are two types of loadbalancer, this type One Arm or Proxy Mode is the simplest, and requires an edge device for each logical network

 

As you can see from the diagram, the loadbalancer looks like an arm stuck on the side of the L2 network

 

NSX-Lab-ESG - Untitled Page (1)

 

First create the load balancer edge

on-lb-2

on-lb-3

oa-lb-4

When adding the interface be sure it is Internal

add-oa-lb-interface

 

on-lb-6

oa-lb-7

Once the edge is deployed

 

Enable load balancing

oa-lb-8

Create the application profile
As ssl has not been configured I’m using TCP to keep it simple, the port will be specified in the next step

application-profile

Create a Pool and add each of the web servers, be sure to specify port 80 for both monitor and port
I am going to use Leastconn, and the default_tcp_monitor

oa-lb-pool

Finally add a virtual server

oa-lb-vs

 

Once the virtual server is deployed check that the pool is up

oa-lb-poolup

 

Then test, with each refresh the server will alternate

test

 

 

 

ssh to the loadbalancer edge and run the following commands

# show service loadbalancer
OneArmed-LoadBalancer-0> show service loadbalancer
-----------------------------------------------------------------------
L7 Loadbalancer Sticky Table Status:

TABLE                          TYPE                 SIZE(BYTE)      USED(BYTE)
OneArmed-LoadBalancer-0> show service loadbalancer
-----------------------------------------------------------------------
Loadbalancer Services Status:

L7 Loadbalancer     : running
-----------------------------------------------------------------------
L7 Loadbalancer Status Information:
STATUS     PID        MAX_MEM_MB MAX_SOCK   MAX_CONN   MAX_PIPE   CUR_CONN   CONN_RATE  CONN_RATE_LIMIT MAX_CONN_RATE
running    7520       0          2081       1024       0          0          0          0               0
-----------------------------------------------------------------------
L4 Loadbalancer Statistics:
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn


# show service loadbalancer virtual [vip-name]
OneArmed-LoadBalancer-0> show service loadbalancer virtual virtual-ip
-----------------------------------------------------------------------
Loadbalancer VirtualServer Statistics:

VIRTUAL virtual-ip
|  ADDRESS [172.16.10.16]:80
|  SESSION (cur, max, total) = (0, 3, 42)
|  RATE (cur, max, limit) = (0, 3, 0)
|  BYTES in = (21305), out = (123755)
   +->POOL Web-Servers-Pool
   |  LB METHOD leastconn
   |  LB PROTOCOL L7
   |  Transparent disabled
   |  SESSION (cur, max, total) = (0, 2, 56)
   |  BYTES in = (21305), out = (122583)
      +->POOL MEMBER: Web-Servers-Pool/web-1, STATUS: UP
      |  |  HEALTH MONITOR = BUILT-IN, default_tcp_monitor:L4OK
      |  |  |  LAST STATE CHANGE: 2016-01-03 22:11:11
      |  |  SESSION (cur, max, total) = (0, 1, 30)
      |  |  BYTES in = (11608), out = (86980)
      +->POOL MEMBER: Web-Servers-Pool/web-2, STATUS: UP
      |  |  HEALTH MONITOR = BUILT-IN, default_tcp_monitor:L4OK
      |  |  |  LAST STATE CHANGE: 2016-01-03 18:54:25
      |  |  SESSION (cur, max, total) = (0, 1, 26)
      |  |  BYTES in = (9697), out = (35603)



# show service loadbalancer pool [pool-name]
OneArmed-LoadBalancer-0> show service loadbalancer pool  Web-Servers-Pool
-----------------------------------------------------------------------
Loadbalancer Pool Statistics:

POOL Web-Servers-Pool
|  LB METHOD leastconn
|  LB PROTOCOL L7
|  Transparent disabled
|  SESSION (cur, max, total) = (0, 2, 56)
|  BYTES in = (21305), out = (122583)
   +->POOL MEMBER: Web-Servers-Pool/web-1, STATUS: UP
   |  |  HEALTH MONITOR = BUILT-IN, default_tcp_monitor:L4OK
   |  |  |  LAST STATE CHANGE: 2016-01-03 22:11:11
   |  |  SESSION (cur, max, total) = (0, 1, 30)
   |  |  BYTES in = (11608), out = (86980)
   +->POOL MEMBER: Web-Servers-Pool/web-2, STATUS: UP
   |  |  HEALTH MONITOR = BUILT-IN, default_tcp_monitor:L4OK
   |  |  |  LAST STATE CHANGE: 2016-01-03 18:54:25
   |  |  SESSION (cur, max, total) = (0, 1, 26)
   |  |  BYTES in = (9697), out = (35603)

Check Service Monitor status (OK, WARNING, CRITICAL)

# show service loadbalancer monitor
OneArmed-LoadBalancer-0> show service loadbalancer monitor
-----------------------------------------------------------------------
Loadbalancer Health Check Statistics:

MONITOR PROVIDER     POOL                           MEMBER                         HEALTH STATUS
built-in             Web-Servers-Pool               web-1                          default_tcp_monitor:L4OK
built-in             Web-Servers-Pool               web-2                          default_tcp_monitor:L4OK
OneArmed-LoadBalancer-0>


Check session table

# show service loadbalancer session
OneArmed-LoadBalancer-0> show service loadbalancer session
-----------------------------------------------------------------------
L7 Loadbalancer Current Sessions:

0x64c47473610: proto=unix_stream src=unix:1 fe=GLOBAL be=<NONE> srv=<none> ts=09 age=0s calls=2 rq[f=c08200h,i=0,an=00h,rx=20s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=1,ex=] s1=[7,0h,fd=-1,ex=] exp=19s

-----------------------------------------------------------------------
L4 Loadbalancer Current Sessions:
pro expire state       source             virtual            destination

 

Once done, disconnect the network on web-1 and recheck, the pool stats and and look at the output of the above