Forum Discussion

Cl__i_14987's avatar
Cl__i_14987
Icon for Nimbostratus rankNimbostratus
Nov 08, 2013

Loadbalance Web server

Dear all, I have problem with loadbalance web server (in by Lab test). so I do my Lab test to test loadbalance web server(CentOS). - F5 internal: 1.1.1.1/24, external: 2.2.2.1/24 - Web server (web01): 1.1.1.5/24, (web02): 1.1.1.6/24, VIP: 2.2.2.7/24 - loadbalance method: roundrobin, persistence: none issue: 1. when I tried to test access web server from loadbalancing by F5, it worked for html page with text. (web01) Hello F5 (web02) Bye F5 2. So when I tried to test access web server with picture. It didn't loadbalance webpage just only stay in first page only web01 sometimes change to web02. (I monitor on the pool statistic the packet and connection also load balance but output doesn't change) (web01) (web02)

 

Best regards

 

9 Replies

  • Hi,

     

    Did you check that your web browser is not caching pictures for those web sites ?

     

  • Here are steps to disable caching in IE :

     

    Click "Internet Options.

     

    Click the "General" tab in the dialog box that appears.

     

    Click the "Settings" button under "Temporary Internet Files.

     

    Click the box next to "Every Visit to the Page" under the "Check for Newer Versions of Stored Pages" option.

     

    Click "Save." The cache is now permanently disabled unless you manually change it back to its previous settings.

     

  • Hi It can swap page with picture only 2 times after your suggestion and then every thing it same. (cannot swap web page with image)

     

    (but the monitoring on the pool statistic the packet and connection also load balance but output doesn't change)

     

  • Did you try another web browser? I don't have access to IE so I can't test anything on it. Don't know if it works on IE but try to do Ctrl+F5 or Shift+F5 keystrokes to refresh your web page.

     

  • I already try all of these (IE, Firefox, Chrome,) but still same result.

     

  • If I may add, if I understand you correctly, you want the pool member selection to be "in-sticky", so that when you make multiple requests, you flip back and forth between the members. Is that correct? If so, there are a few considerations:

     

    1. Understand that load balancing is generally a layer 4 mechanism. You can affect a load balancing decision at different levels, but once a member is selected that selection will, regardless of load balancing method, persist for the life of that TCP session. If you open a browser, get a particular pool member, and then refresh repeatedly and quickly, you will most likely keep that single TCP session alive and continue to persist to the same member. If you pause long enough to let the TCP session expire, and HTTP isn't setting a Keep-Alive in the browser, then a subsequent request will probably re-load balance to the next member. Enabling a OneConnect profile on the VIP can help, or using an iRule to force the TCP session to close with a "Connection: Close" header in the HTTP responses.

       

    2. If you watch the HTTP communications between the client and VIP, you may see cache control headers in either the requests or responses. Sometimes, regardless of client side cache settings, a browser will still send out an If-Modified-Since header, and the server might respond with a 304. This would be especially important if the images on both pool members had the same name.

       

  • Hi Kevin

     

    I tried to enable oneconnect profile(default profile). but still same result.

     

    Can you give me some example to create iRule with TCP session to close to virtual server.

     

  • Here is an iRule to inject/manage cache control headers:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            "*.jpg" -
            "*.png" -
            "*.gif" {
                set uncache 1
                HTTP::header remove "If-Modified-Since"
                HTTP::header remove "If-None-Match"
            }
        }
    }
    when HTTP_RESPONSE {
        if { [info exists uncache] } {
            unset uncache
            HTTP::header remove "Etag"
            HTTP::header insert "Cache-Control" "no-cache"
        }
    }
    

    This is only going to affect requests for specific image types. If you're load balancing servers with different content, you don't necessarily want to force a TCP session closure after each request. For example, let's say you load balance to a server that makes an img src reference to "/image1.png". You serve the page and then close the connection. When the browser makes its request for "/image.png", it's going to initiate a new load balancing decision, and potentially land on a server that does not have this image. The above will make sure that like image names aren't cached across requests, but you'll still probably want to leave the TCP session alone (which usually defaults to about 5 seconds). If you refresh your browser every 6 seconds, you should see the images swap. Alternately you can adjust both the TCP and HTTP Keep-Alive time out values, but do so with care.