Re: Varnish and sticky sessions
JT Justman wrote: > Never tried it, but it seems to me you could read a cookie in VCL to > determine the backend to use. This is how most load balancers handle > sticky sessions, right? That's one way. Another way that doesn't involve cookies or server side session tables and which is generally more performant (if performance is of any relevance here) is to hash some client endpoint identifier and calculate the modulus with the number of available backend servers. As client endpoint identifier you could use the decimal representation of it's ip address. So: decimal Client IP = (first octet * 256**3) + (second octet * 256**2) + (third octet * 256) + (fourth octet) Sticky Client Backend = decimal Client IP % Number of available Backend Servers Example: Client IP = 10.129.40.22 Number of available Backend Servers = e.g. 4 therefor: Decimal Client IP = (10 * 16777216) + (129 * 65536) + (40 * 256) + (22) Decimal Client IP = 176236566 Sticky Client Backend = 176236566 % 4 = 2 Or if VCL doesn't support the modulo operator, calculate it using basic arithmetic operations: 176236566 / 4 = 44059141.5 4 * 44059141 = 176236564 176236566 - 176236564 = 2 So in this case the client always get's balanced to the third backend server (range is 0 - 3). It would only get rebalanced if the number of available backend servers changes. I.e. if a backend server fails or one is added. Instead of the client's dec IP you could also create some hash using a combination of client IP and browser name, or something like that.. depends on what your requirements are and who your site's target audience is. If your site gets lots of traffic from companies who generally NAT their employees using one or two gateway IPs than hashing based on the client IP alone wouldn't do much good. However if the site's target audience are end-users sitting at home each with their own IP it's a very efficient and well balanced way of doing sticky sessions. I really don't know enough about available VCL operators and syntax, but from taking a quick look at it I saw that it's pretty flexible, even supporting regexp (personally wouldn't use them for request balancing though) and inline C Code. So if the required hashing and char matching functions aren't present in VCL itself it seems you could easily do them in C. As far as the number of available backend servers go, I don't know if they get exposed by varnish inside VCL. You could always hard code them of course but it would be better if varnish itself had some way to let you know which backend servers it considers alive and which not. This might require some modifications to varnish itself if they aren't already present. Anyway, the method described is a valid way to do sticky sessions and supported by most commercial load balancers. It's very resource friendly as it doesn't involve any cookie parsing/setting or server side session tables. Cheers, -- Lukas ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: Varnish and sticky sessions
Torstein Krause Johansen wrote: > Heya, > > is there a way to get Varnish load balancing (the director) to support > sticky sessions? > > Or do I need to put a load balancer behind the Varnish that ensures that > a client with a given session always goes to the same backend server? Never tried it, but it seems to me you could read a cookie in VCL to determine the backend to use. This is how most load balancers handle sticky sessions, right? -- [EMAIL PROTECTED] http://www.endpoint.com ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Varnish and sticky sessions
Heya, is there a way to get Varnish load balancing (the director) to support sticky sessions? Or do I need to put a load balancer behind the Varnish that ensures that a client with a given session always goes to the same backend server? Right now, it looks like I need: LB -> apache1/mod_inflate -> varnish/esi -> apache2/mod_proxy_balancer -> app servers to get ESI support, gzip-ed content delivered to the client and sticky sessions Cheers, -Torstein -- Torstein Krause Johansen System architect mobile: +47 97 01 76 04 web: http://www.escenic.com/ Escenic - platform for innovation ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: ESI works in IE6 & curl, but not in FF, Opera, Konqueror
Hi JT, JT Justman wrote: > We have a client who is interested in ESI and also requires gzip (as I > think most would), and we've been working on it on the back burner for a > while. Faster work from us depends on the client's priorities. It's not > a trivial undertaking, but I have at least got to the point of > understanding the ESI request flow enough to guess where the encoding > should probably be performed. > > See here for links to two bugs discussing the issue: thanks for the additional info regarding the ESI/gzip issue. Although it would be grand if Varnish supports gzip nativelly, currently I don't see a big problem of putting the Apache infront of Varnish instead of behind it. Hopefully we'll get the desired effect then. Cheers, -Torstein -- Torstein Krause Johansen System architect mobile: +47 97 01 76 04 web: http://www.escenic.com/ Escenic - platform for innovation ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: Wishlist: filtering for varnishhist
In message <[EMAIL PROTECTED]>, "Ole L aursen" writes: >Hi, > >Varnishhist is pretty cool. Unfortunately, most of my data comes from >image files which are served by a well-functioning lighttpd instance. >So I'm really only interested in the data from the Apache web server >running Django. See point 8: http://varnish.projects.linpro.no/wiki/PostTwoShoppingList -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 [EMAIL PROTECTED] | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc
Re: Conditional GET (was Re: caching using ETags to vary the content)
In message <[EMAIL PROTECTED]>, Ryan Tomayko writes: >On 11/12/08 3:19 AM, Ricardo Newbery wrote: >Right. Sorry about the ambiguity in my original message. I'm asking >specifically about Varnish using If-Modified-Since/If-None-Match to >revalidate a stale cache entry with the backend. > >Can anyone say whether the lack of validation is due to a conscious >design decision as opposed to something that just hasn't been >implemented due to priority/time/resources? Both, it hasn't been deemed important enough yet for it to happen. >I'd be willing to take a crack at some of this if it's something that >would be considered for inclusion in the project. It's slightly involved, because presently we don't hold on to a reference to the object that we might revalidate, so the change is semi-nasty locking wise. That said, we're happy to receive patches. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 [EMAIL PROTECTED] | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. ___ varnish-misc mailing list varnish-misc@projects.linpro.no http://projects.linpro.no/mailman/listinfo/varnish-misc