Re: Varnish load balancer & (keep session)
Hi, To answer some of your questions: 1) 503 error when shutting down a backend: When you shutdown the backend, do you see varnishlog say that the backend is healthy or sick? If one is sick, then the other should get the traffic if your VCL contains set req.backend = b1; 2) Vanish load balanced does not keep e-commerce sessions for PHP. The simplest solution to this is to install memcache, and put the following lines in your php.ini file: [Session] session.save_handler = memcached session.save_path = "memcache-server1:11211,memcache-server2:11211" instead of session.save_handler = files However, I can't say for certain that this will definitely work - it depends on how your ecommerce application operates. 3) S-flag: I'm not sure about this, but my gut feeling is that it's not causing the problems you're seeing. Rob alertebox wrote: > > Version: 2.0.6-1 > > Insall: .deb > > Os: Debian 5.0.3 > > Hi, > > I've got two backends running apache2: front1.domain.com & > front2.domain.com, set with the load balancing configuration > from http://varnish-cache.org/wiki/LoadBalancing. > > _The issue is, when I shutdown apache2 of the first backend varnish > don't switch to the second and display "Error 503 Service > Unavailable", is that a normal answer from varnish?_ > > Other question, _does varnish load balancer keep php sessions for > e-commerce, if yes how will I do?_ > > Varnishlog : > > 0 Backend_health - front1 Still healthy 4--X-RH 10 8 10 0.040008 > 0.039814 HTTP/1.1 200 OK > > 0 Backend_health - front2 Still healthy 4--X-RH 10 8 10 0.066948 > 0.066591 HTTP/1.1 200 OK > > _The S flag is missing in my log, is that an issue…_ > > "4--X-S-RH" to notify that TCP socket shutdown succeeded > from http://varnish-cache.org/wiki/BackendPolling > > Part of default.vcl > > backend front1 { > > .host = "front1.domain.com"; > > .port = "80"; > > .probe = { .url = "/"; > > .interval = 10s; > > .timeout = 5s; > > .window = 10; > > .threshold = 8; > > } > > } > > > > backend front2 { > > .host = "front2.domain.com"; > > .port = "80"; > > .probe = { .url = "/"; > > .interval = 10s; > > .timeout = 5s; > > .window = 10; > > .threshold = 8; > > } > > } > > > > director b1 random > > { > >{ .backend = front1; .weight = 1; } > >{ .backend = front2; .weight = 1; } > > } > > > > #director b1 round-robin { > > #{ .backend = front1; } > > #{ .backend = front2; } > > #} > > _Is that part of configuration is wrong_ ? > > > > Thanks for your help... > > > > > > ___ > varnish-misc mailing list > varnish-misc@projects.linpro.no > http://projects.linpro.no/mailman/listinfo/varnish-misc > ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: Varnish load balancer & (keep session)
Hi, To answer some of your questions: 1) 503 error when shutting down a backend: When you shutdown the backend, do you see varnishlog say that the backend is healthy or sick? If one is sick, then the other should get the traffic if your VCL contains set req.backend = b1; 2) Vanish load balanced does not keep e-commerce sessions for PHP. The simplest solution to this is to install memcache, and put the following lines in your php.ini file: [Session] session.save_handler = memcached session.save_path = "memcache-server1:11211,memcache-server2:11211" instead of session.save_handler = files However, I can't say for certain that this will definitely work - it depends on how your ecommerce application operates. 3) S-flag: I'm not sure about this, but my gut feeling is that it's not causing the problems you're seeing. Rob Axel DEAU wrote: > > Version: 2.0.6-1 > > Insall: .deb > > Os: Debian 5.0.3 > > Hi, > > I've got two backends running apache2: front1.domain.com & > front2.domain.com, set with the load balancing configuration > from http://varnish-cache.org/wiki/LoadBalancing. > > _The issue is, when I shutdown apache2 of the first backend varnish > don't switch to the second and display "Error 503 Service > Unavailable", is that a normal answer from varnish?_ > > Other question, _does varnish load balancer keep php sessions, if yes > how will I do?_ > > Varnishlog : > > 0 Backend_health - front1 Still healthy 4--X-RH 10 8 10 0.040008 > 0.039814 HTTP/1.1 200 OK > > 0 Backend_health - front2 Still healthy 4--X-RH 10 8 10 0.066948 > 0.066591 HTTP/1.1 200 OK > > The S flag is missing in my log, is that an issue… > > "4--X-S-RH" to notify that TCP socket shutdown succeeded > from http://varnish-cache.org/wiki/BackendPolling > > Part of default.vcl > > backend front1 { > > .host = "front1.domain.com"; > > .port = "80"; > > .probe = { .url = "/"; > > .interval = 10s; > > .timeout = 5s; > > .window = 10; > > .threshold = 8; > > } > > } > > > > backend front2 { > > .host = "front2.domain.com"; > > .port = "80"; > > .probe = { .url = "/"; > > .interval = 10s; > > .timeout = 5s; > > .window = 10; > > .threshold = 8; > > } > > } > > > > director b1 random > > { > >{ .backend = front1; .weight = 5; } > >{ .backend = front2; .weight = 1; } > > } > > > > #director b1 round-robin { > > #{ .backend = front1; } > > #{ .backend = front2; } > > #} > > Thanks for your help... > > > > ___ > varnish-misc mailing list > varnish-misc@projects.linpro.no > http://projects.linpro.no/mailman/listinfo/varnish-misc > ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: Varnish load balancer & (keep session)
Axel - Can I assume you have a single Varnish instance balancing over the two Apache instances? If so, then another option would be to use some kind of home-grown source IP stickyness to force connections from one half of the Internet to one backend, and connections from the other half to the other backend. I'm not sure if you'd need to dip into C, but it should be possible to do something like "if (srcip % 2 == 0) { backend = b1; } else { backend = b2; }" You can still support failover by calling checking the status of backend.healthy, and change the backend to the alternative if the preferred one is down. Thanks, Sam On 7 February 2010 12:33, Rob S wrote: > Hi, > > To answer some of your questions: > > 1) 503 error when shutting down a backend: When you shutdown the > backend, do you see varnishlog say that the backend is healthy or sick? > If one is sick, then the other should get the traffic if your VCL > contains set req.backend = b1; > > 2) Vanish load balanced does not keep e-commerce sessions for PHP. The > simplest solution to this is to install memcache, and put the following > lines in your php.ini file: > > [Session] > session.save_handler = memcached > session.save_path = "memcache-server1:11211,memcache-server2:11211" > > instead of session.save_handler = files > > However, I can't say for certain that this will definitely work - it > depends on how your ecommerce application operates. > > 3) S-flag: I'm not sure about this, but my gut feeling is that it's not > causing the problems you're seeing. > > > > Rob > > > Axel DEAU wrote: >> >> Version: 2.0.6-1 >> >> Insall: .deb >> >> Os: Debian 5.0.3 >> >> Hi, >> >> I've got two backends running apache2: front1.domain.com & >> front2.domain.com, set with the load balancing configuration >> from http://varnish-cache.org/wiki/LoadBalancing. >> >> _The issue is, when I shutdown apache2 of the first backend varnish >> don't switch to the second and display "Error 503 Service >> Unavailable", is that a normal answer from varnish?_ >> >> Other question, _does varnish load balancer keep php sessions, if yes >> how will I do?_ >> >> Varnishlog : >> >> 0 Backend_health - front1 Still healthy 4--X-RH 10 8 10 0.040008 >> 0.039814 HTTP/1.1 200 OK >> >> 0 Backend_health - front2 Still healthy 4--X-RH 10 8 10 0.066948 >> 0.066591 HTTP/1.1 200 OK >> >> The S flag is missing in my log, is that an issue… >> >> "4--X-S-RH" to notify that TCP socket shutdown succeeded >> from http://varnish-cache.org/wiki/BackendPolling >> >> Part of default.vcl >> >> backend front1 { >> >> .host = "front1.domain.com"; >> >> .port = "80"; >> >> .probe = { .url = "/"; >> >> .interval = 10s; >> >> .timeout = 5s; >> >> .window = 10; >> >> .threshold = 8; >> >> } >> >> } >> >> >> >> backend front2 { >> >> .host = "front2.domain.com"; >> >> .port = "80"; >> >> .probe = { .url = "/"; >> >> .interval = 10s; >> >> .timeout = 5s; >> >> .window = 10; >> >> .threshold = 8; >> >> } >> >> } >> >> >> >> director b1 random >> >> { >> >> { .backend = front1; .weight = 5; } >> >> { .backend = front2; .weight = 1; } >> >> } >> >> >> >> #director b1 round-robin { >> >> # { .backend = front1; } >> >> # { .backend = front2; } >> >> #} >> >> Thanks for your help... >> >> >> >> ___ >> varnish-misc mailing list >> varnish-misc@projects.linpro.no >> http://projects.linpro.no/mailman/listinfo/varnish-misc >> > > ___ > varnish-misc mailing list > varnish-misc@projects.linpro.no > http://projects.linpro.no/mailman/listinfo/varnish-misc > ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: Varnish load balancer & (keep session)
Just to copy in the list... the problem Axel was seeing is one that troubled us for a bit - getting unexpected 503 responses. Solution: Make sure the top of "sub vcl_recv" has a default backend: set req.backend = xxx; You can override this later with conditional statements, or whatever, but having a default helps prevent 503s. Rob Axel DEAU wrote: > Hi, > > It seems that with this method it works very well I thanks you a lot for your > help and wich you have a nice day > > Best regard > > Axel DEAU | NOVACTIVE SYTEME > > Administrateur Systeme et Reseaux > mail : a.d...@novactive-systemes.com > Tel : + 33 1 48 24 33 60 > Fax : + 33 1 48 24 33 54 > www.novactive.com > > > -Message d'origine- > De : Rob S [mailto:rtshils...@gmail.com] > Envoyé : lundi 8 février 2010 11:50 > À : Axel DEAU > Cc : Sacha MILADINOVIC > Objet : Re: Varnish load balancer & (keep session) > > At the very top of "sub vcl_recv", please add: > > set req.backend = b1; > > This will set the default backend. > > Can you also send me the output of > > # varnishlog |grep Backend_health > 0 Backend_health - server7 Still healthy 4--X-S-RH 10 8 10 0.007498 > 0.009539 HTTP/1.1 200 OK > 0 Backend_health - server2 Still healthy 4--X-S-RH 10 8 10 0.006767 > 0.013814 HTTP/1.1 200 OK > 0 Backend_health - server3 Still healthy 4--X-S-RH 10 8 10 0.012027 > 0.010841 HTTP/1.1 200 OK > > from before and after you stop apache on the first and second backends. > > > Rob > > > Axel DEAU wrote: > >> Hi, >> >> Absolutely >> >> Axel DEAU | NOVACTIVE SYTEME >> >> Administrateur Systeme et Reseaux >> mail : a.d...@novactive-systemes.com >> Tel : + 33 1 48 24 33 60 >> Fax : + 33 1 48 24 33 54 >> www.novactive.com >> >> >> -Message d'origine- >> De : Rob S [mailto:rtshils...@gmail.com] >> Envoyé : lundi 8 février 2010 10:24 >> À : Axel DEAU >> Cc : Sacha MILADINOVIC >> Objet : Re: Varnish load balancer & (keep session) >> >> Axel, >> >> Can you post your entire VCL, and I'll see why this is happening. >> >> Rob >> >> Axel DEAU wrote: >> >> >>> Hi Rob, >>> >>> Thanks for the reply, for 1) when I shut down the second backend all the >>> traffic goes to the first backend but, >>> When I shut down the first backend even if the second backend mark "Still >>> healthy" the error 503 appears. >>> >>> For the other point I'm agreed with you... >>> >>> -Message d'origine- >>> De : Rob S [mailto:rtshils...@gmail.com] >>> Envoyé : dimanche 7 février 2010 13:33 >>> À : Axel DEAU >>> Cc : varnish-misc@projects.linpro.no >>> Objet : Re: Varnish load balancer & (keep session) >>> >>> Hi, >>> >>> To answer some of your questions: >>> >>> 1) 503 error when shutting down a backend: When you shutdown the >>> backend, do you see varnishlog say that the backend is healthy or sick? >>> If one is sick, then the other should get the traffic if your VCL >>> contains set req.backend = b1; >>> >>> 2) Vanish load balanced does not keep e-commerce sessions for PHP. The >>> simplest solution to this is to install memcache, and put the following >>> lines in your php.ini file: >>> >>> [Session] >>> session.save_handler = memcached >>> session.save_path = "memcache-server1:11211,memcache-server2:11211" >>> >>> instead of session.save_handler = files >>> >>> However, I can't say for certain that this will definitely work - it >>> depends on how your ecommerce application operates. >>> >>> 3) S-flag: I'm not sure about this, but my gut feeling is that it's not >>> causing the problems you're seeing. >>> >>> >>> >>> Rob >>> >>> >>> Axel DEAU wrote: >>> >>> >>> >>>> Version: 2.0.6-1 >>>> >>>> Insall: .deb >>>> >>>> Os: Debian 5.0.3 >>>> >>>> Hi, >>>> >>>> I've got two backends running apache2: front1.domain.com & >>>> front2.domain.com, set with the load balancing configuration >>>> from http://varnish-cache.org/wiki/LoadBalancing. >>>> >>>> _The issue is, when I shutdown apache2 of the first backend
Re: Varnish load balancer & (keep session)
While this might be somewhat "hammering" backends (in case something goes totally wrong) we have ironed out a lot (if not all) 503 errors just by rerequesting the objects (in our case usually a static image) which get the 503 response by adding this: sub vcl_error { if (obj.status == 503 && req.restarts < 4) { restart; } } rr - Original Message - From: "Rob S" > Just to copy in the list... the problem Axel was seeing is one that > troubled us for a bit - getting unexpected 503 responses. > > Solution: Make sure the top of "sub vcl_recv" has a default backend: > > set req.backend = xxx; > > You can override this later with conditional statements, or whatever, > but having a default helps prevent 503s. > > > Rob > > > Axel DEAU wrote: >> Hi, >> >> It seems that with this method it works very well I thanks you a lot for >> your help and wich you have a nice day >> >> Best regard >> >> Axel DEAU | NOVACTIVE SYTEME >> >> Administrateur Systeme et Reseaux >> mail : a.d...@novactive-systemes.com >> Tel : + 33 1 48 24 33 60 >> Fax : + 33 1 48 24 33 54 >> www.novactive.com >> >> >> -----Message d'origine- >> De : Rob S [mailto:rtshils...@gmail.com] >> Envoyé : lundi 8 février 2010 11:50 >> À : Axel DEAU >> Cc : Sacha MILADINOVIC >> Objet : Re: Varnish load balancer & (keep session) >> >> At the very top of "sub vcl_recv", please add: >> >> set req.backend = b1; >> >> This will set the default backend. >> >> Can you also send me the output of >> >> # varnishlog |grep Backend_health >> 0 Backend_health - server7 Still healthy 4--X-S-RH 10 8 10 0.007498 >> 0.009539 HTTP/1.1 200 OK >> 0 Backend_health - server2 Still healthy 4--X-S-RH 10 8 10 0.006767 >> 0.013814 HTTP/1.1 200 OK >> 0 Backend_health - server3 Still healthy 4--X-S-RH 10 8 10 0.012027 >> 0.010841 HTTP/1.1 200 OK >> >> from before and after you stop apache on the first and second backends. >> >> >> Rob >> >> >> Axel DEAU wrote: >> >>> Hi, >>> >>> Absolutely >>> >>> Axel DEAU | NOVACTIVE SYTEME >>> >>> Administrateur Systeme et Reseaux >>> mail : a.d...@novactive-systemes.com >>> Tel : + 33 1 48 24 33 60 >>> Fax : + 33 1 48 24 33 54 >>> www.novactive.com >>> >>> >>> -Message d'origine- >>> De : Rob S [mailto:rtshils...@gmail.com] >>> Envoyé : lundi 8 février 2010 10:24 >>> À : Axel DEAU >>> Cc : Sacha MILADINOVIC >>> Objet : Re: Varnish load balancer & (keep session) >>> >>> Axel, >>> >>> Can you post your entire VCL, and I'll see why this is happening. >>> >>> Rob >>> >>> Axel DEAU wrote: >>> >>> >>>> Hi Rob, >>>> >>>> Thanks for the reply, for 1) when I shut down the second backend all the >>>> traffic goes to the first backend but, >>>> When I shut down the first backend even if the second backend mark "Still >>>> healthy" the error 503 appears. >>>> >>>> For the other point I'm agreed with you... >>>> >>>> -Message d'origine- >>>> De : Rob S [mailto:rtshils...@gmail.com] >>>> Envoyé : dimanche 7 février 2010 13:33 >>>> À : Axel DEAU >>>> Cc : varnish-misc@projects.linpro.no >>>> Objet : Re: Varnish load balancer & (keep session) >>>> >>>> Hi, >>>> >>>> To answer some of your questions: >>>> >>>> 1) 503 error when shutting down a backend: When you shutdown the >>>> backend, do you see varnishlog say that the backend is healthy or sick? >>>> If one is sick, then the other should get the traffic if your VCL >>>> contains set req.backend = b1; >>>> >>>> 2) Vanish load balanced does not keep e-commerce sessions for PHP. The >>>> simplest solution to this is to install memcache, and put the following >>>> lines in your php.ini file: >>>> >>>> [Session] >>>> session.save_handler = memcached >>>> session.save_path = "memcache-server1:11211,memcache-server2:11211" >>>> >>>> instead of session.save_handler = files >>>> >>>> However, I can't say for certain that t