Dropped HTTP Requests

2009-03-06 Thread Timothy Olson
I'm using HAProxy 1.3.15.7 to load-balance three Tomcat instances, and to
fork requests for static content to a single Apache instance.  I've found
that after the initial HTML page is loaded from Tomcat, the browser's
subsequent first request for a static image from Apache gets dropped
(neither HAProxy nor Apache logs the request, but I can sniff it).  The rest
of the images after the first load fine.  If I create a small, static, test
HTML page on Tomcat (making the images come from a different backend), it
shows the first image on the page as broken.  If I put the exact same HTML
page on Apache (no backend switch required), it works fine.  I wonder if we
have a configuration problem, or perhaps this is a bug in the way HAProxy
deals with an HTTP keepalive request that spreads to a second backend?
Here is our simple test HTML page:

htmlbodyimg src=/header/logo.jpgbrimg
src=/header/play_demo.jpg/body/html

Both images come from Apache.  Again, if we request this HTML from the same
backend as the images, it works.  If we request this HTML from the Tomcat
backend, the request to Apache for logo.jpg gets dropped.  Our config
follows:


global
  log 127.0.0.1 local0 notice
  maxconn 4096
  chroot /usr/share/haproxy-jail
  user apache
  group apache
  daemon
  spread-checks 5

defaults
  log global
  modehttp
  option  httplog
  option  dontlognull
  option  forwardfor
  option  redispatch
  retries 3
  timeout connect 4s
  timeout server 20s
  timeout client 10s
  timeout http-request 10s

frontend all
  bind :80
  acl rp path_beg /rp
  acl rp_adserving path_beg /rp/javascript.js or path_beg /rp/do/adserving
  use_backend apache if !rp
  use_backend tomcat_nosession if rp_adserving
  default_backend tomcat_session

backend apache
  server LocalApache localhost:81
  balance roundrobin
  option httpchk /
  stats enable
  stats hide-version
  stats uri /hapstat
  stats realm   Haproxy\ Statistics
  stats authx:xxx
  stats refresh 5s

backend tomcat_session
  server TomcatA out1:8080 cookie A check slowstart 10s
  server TomcatB out2:8080 cookie B check slowstart 10s
  server TomcatC out3:8080 cookie C check slowstart 10s
  balance roundrobin
  option httpchk /rp/index.html
  timeout server 2m
  cookie JSESSIONID prefix

backend tomcat_nosession
  server TomcatA out1:8080 check slowstart 10s
  server TomcatB out2:8080 check slowstart 10s
  server TomcatC out3:8080 check slowstart 10s
  balance roundrobin
  option httpchk /rp/index.html


Re: Dropped HTTP Requests

2009-03-06 Thread Willy Tarreau
On Fri, Mar 06, 2009 at 04:55:21PM -0500, Timothy Olson wrote:
 I'm using HAProxy 1.3.15.7 to load-balance three Tomcat instances, and to
 fork requests for static content to a single Apache instance.  I've found
 that after the initial HTML page is loaded from Tomcat, the browser's
 subsequent first request for a static image from Apache gets dropped
 (neither HAProxy nor Apache logs the request, but I can sniff it).  The rest
 of the images after the first load fine.  If I create a small, static, test
 HTML page on Tomcat (making the images come from a different backend), it
 shows the first image on the page as broken.  If I put the exact same HTML
 page on Apache (no backend switch required), it works fine.  I wonder if we
 have a configuration problem, or perhaps this is a bug in the way HAProxy
 deals with an HTTP keepalive request that spreads to a second backend?

Haproxy does not support HTTP keepalive yet. However it can workaround it
using option httpclose, which you should set in your defaults section.
What you describe is typically what happens without the option.

Regards,
Willy