Forum Discussion

juergen_lampar1's avatar
juergen_lampar1
Icon for Nimbostratus rankNimbostratus
Jun 24, 2014

dynamic loadbalancing using value from node

hi, can i dynamic loadbalaning with values from the node´s application? the application writes a score from 1 to 10 in a file. can the LTM this score in a table writing and the node with the best score becomes the next Client Connection? Thanks in Advance.

 

7 Replies

  • LTM wouldn't be able to look at a file on the machine, at least I've never seen anyone do it. You could probably write an iRule to check against a web page and look for that value 1 through 10 then route traffic to that node based on the value.

     

    There may be a simpler option though, could you tell us what kind of problems you are running into that prompted this?

     

    • Brad_146558's avatar
      Brad_146558
      Icon for Nimbostratus rankNimbostratus
      I stand corrected, it looks like you can read a file using LTM.
  • hi, the application can write a score in a file on the Server (node). the LTM should read this value in this file via a Monitor and the Server (Node) with the best score should become the next Client Connection.

     

  • Two things worth considering:

    1. If you needed this to be a real-time thing, then you'd necessarily have to query each server and compare scores on each new user session. To do this you'd use a series of sideband calls inside an iRule, and that would invariable add some latency.

    2. Doing this in a monitor makes it, by definition, an asynchronous process, so you could just as well have a script poll all of the servers periodically and then update ratio values of a given pool. Something like this:

      !/bin/bash
      
       define pool name
      pool="local-pool";
      
       define pool member listener port
      port=80;
      
      arr=($(tmsh list ltm pool $pool |grep address |awk -F" " '{ print $2 }'));
      
      for x in "${arr[@]}"
      do
          score=`curl -fNs http://$x/score.php`;
          tmsh modify ltm pool $pool members modify { $x:$port { ratio $score } };
      done
      
  • Hi, the command "tmsh list ltm pool $pool |grep address " is for Version 11.X But in Version 10.2.4 the scrpit don´t running. The Output differ:

     

    [root@F5:Active] config tmsh list ltm pool testerle_80 |grep address[root@F5:Active] config

     

    [root@F5:Active] config tmsh list ltm pool testerle_80 |grep 192 192.168.212.67:http { 192.168.212.67:hosts2-ns {

     

  • hi, with Version 10.2.4:

    !/bin/bash define pool name

    pool="local-pool";

    define pool member listener port

    port=80;

    arr=($(tmsh list ltm pool $pool |grep "local ip range" | cut -d : -f1 ));

    for x in "${arr[@]}" do score=

    curl -fNs http://$x/score.php
    ; tmsh modify ltm pool $pool members modify { $x:$port { ratio $score } }; done

    but can i Trigger the script via external montior?

  • but can i Trigger the script via external montior?

     

    Absolutely, and there a few ways to do this. The easiest is simply to place that script in /config/monitors, then create an external monitor script in the GUI that points to this script and assigns a bogus pool. You need the pool assignment to make the monitor work, though it doesn't have to be tied to anything that you actually care about. Doing it this way also ensures that everything is backed up in an archive.