Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a varnish 4 in front of an Apache web server. All is good, except i have some random 502 errors.

What is strange is that there is nothing in the varnishlog file for this error ! (all others requests are logged)

My parameters : VARNISH_MIN_THREADS=50 VARNISH_MAX_THREADS=1000 VARNISH_THREAD_TIMEOUT=120

What i can do in order to fix this ?

My default.vcl :

vcl 4.0;

backend default {
  .host = "127.0.0.1";
  .port = "8055";
}

backend php53 {
  .host = "127.0.0.1";
  .port = "8053";
}

sub vcl_recv {
  # Compatiblity with Apache log
  if (req.http.X-Forwarded-For) {
    set req.http.X-Forwarded-For = client.ip;
  } else {
    set req.http.X-Forwarded-For = client.ip;
  }

  if (
    req.http.Host ~ "site1" ||
    req.http.Host ~ "site2")
  {
    set req.backend_hint = php53;
  }

  if (req.http.Host ~ "mainsite" ){
    if (req.method == "POST") {
       return (pipe);
    }
    if (req.method == "GET" && (req.url ~ "^/admin")) {
       return (pass);
    }
  }

  if (req.method != "GET" && req.method != "HEAD")
  {
    return (pass);
  }

  if (req.url ~ "(?i)\.(jpeg|jpg|png|gif|ico)$") {
    unset req.http.Cookie;
    return (hash);
  } else {
    return (pass);
  }
}
sub vcl_backend_response {
   if (beresp.http.Content-Length !~ "[0-9]{7,10}") {
     return(deliver);
   }
}

i have 502 errors on 'mainsite' (prestashop ecommerce, with lot of images)

My current stat :

MAIN.uptime 151353 1.00 Child process uptime MAIN.sess_conn 59309 0.39 Sessions accepted

MAIN.sess_drop 0 0.00 Sessions dropped

MAIN.sess_fail 0 0.00 Session accept failures

MAIN.backend_conn 24076 0.16 Backend conn. success

MAIN.backend_unhealthy 0 0.00 Backend conn. not attempted

MAIN.backend_busy 0 0.00 Backend conn. too many

MAIN.backend_fail 85 0.00 Backend conn. failures

MAIN.backend_reuse 53606 0.35 Backend conn. reuses

MAIN.backend_toolate 11249 0.07 Backend conn. was closed

MAIN.backend_recycle 64856 0.43 Backend conn. recycles

MAIN.backend_retry 0 0.00 Backend conn. retry

MAIN.threads 100 . Total number of threads

MAIN.threads_created 108 0.00 Threads created

MAIN.threads_destroyed 8 0.00 Threads destoryed

MAIN.threads_failed 0 0.00 Thread creation failed

MAIN.busy_sleep 3 0.00 Number of requests sent to sleep on busy objhdr

MAIN.busy_wakeup 3 0.00 Number of requests woken after sleep on busy objhdr

MAIN.sess_queued 11 0.00 Sessions queued for thread

ps aux | grep -i varnish | grep -v grep :

root     22319  0.0  0.5 121896 84060 ?        SLs  12:21   0:00 /usr/sbin/varnishd -P    /var/run/varnish.pid -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread_pool_min=50 -p thread_pool_max=1000 -p thread_pool_timeout=120 -u varnish -g varnish -S /etc/varnish/secret -s malloc,1G
varnish  22321  0.4  0.5 321348 92604 ?        Sl   12:21   0:00 /usr/sbin/varnishd -P /var/run/varnish.pid -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread_pool_min=50 -p thread_pool_max=1000 -p thread_pool_timeout=120 -u varnish -g varnish -S /etc/varnish/secret -s malloc,1G
share|improve this question
    
could be various reason, please paste your config file's to give you right direction. it could be temp error/ proxy error/ server overload or purge. –  tike Jul 1 at 16:41
    
Thanks for your comment. I have updated my question –  griotteau Jul 2 at 8:03

1 Answer 1

have you looked into apache error log for "mainsite" ?

paste output of :

ps aux | grep -i varnish | grep -v grep

And see if your malloc size is not big to serve big contents size

Try: beresp.http.Content-Length !~ "keep this size small" (if that is the case) Note: change that to regex to meet ur requirement where it says keep this size small

and check if you still get that error,

share|improve this answer
    
i add sub vcl_backend_response { if (beresp.http.Content-Length !~ "[0-9]{7,10}") { return(deliver); } } then restart varnish : it's the same –  griotteau Jul 2 at 10:23
    
nothing on apache log (which is normal because there is also no log on varnishlog ?) –  griotteau Jul 2 at 10:27
    
doesnot sound normal if you have 502's and not see error log –  tike Jul 2 at 11:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.