varnish 4 to cache from multiple servers with different content
Guillaume Quintard
guillaume at varnish-software.com
Fri Nov 25 18:20:43 CET 2016
Please keep the mailing list in the loop, this is an open conversation.
OK, so your vcl is wrong and the round-robin is not what you want.
Get rid of you vcl_init (wrong in your case) and vcl_hash (this is the
default one, no need for it, at least for now), and use something like:
sub vcl_recv {
if (req.http.host == "foo.com") {
set req.backend_hint == s1;
} else {
set req.backend_hint == s2;
}
}
On Nov 25, 2016 17:41, "Sreenath Kodedala" <vedarad at gmail.com> wrote:
I might be asking something different.
My two backends will return two different contents and should be able to
cache both the objects depending on backend hostname or ip address.
And should return the appropriate cached object depending on the what
backend it will be used while load-balancing. Not sure if I was clear.
--
Sreenath
On Fri, Nov 25, 2016 at 11:22 AM, Guillaume Quintard <
guillaume at varnish-software.com> wrote:
> Hi,
>
> There's no stickyness involved with the round-robin director. But from
> what you are describing, Varnish is doing what you ask it to do: it caches
> from one backend and keep serving the cached content (ie. it doesn't need
> to go to the backends anymore).
>
> If you wish to have a non-caching loadbalancer, then then "return (pass);"
> at the end of vcl_recv and you'll be ok.
>
> Otherwise, what behavior do you wish to obtain?
>
> --
> Guillaume Quintard
>
> On Wed, Nov 23, 2016 at 3:59 PM, Sreenath Kodedala <vedarad at gmail.com>
> wrote:
>
>> http://stackoverflow.com/questions/40751646/varnish-4-to-cac
>> he-from-multiple-servers-with-different-content
>>
>>
>> Using varnish 4 to cache different content of same request from multiple
>> servers. It looks like it caches the first request from one server and
>> keeps giving the same content for every subsequent request.
>>
>> doing curl gives response with two caches and different age.
>>
>> Are there any factors like load or anything else for stickiness
>> behaviour? Used Jmeter and apache benchmark with load but still got the
>> same behaviour.
>>
>> Is my vcl_hash is good? Want to save the object with hash combination of
>> url and ip of backend server.
>>
>> am I missing anything?
>>
>> using round robin and hash_data. below is my config.vcl
>>
>> backend s1{
>> .host = "190.120.90.1";
>> }
>>
>> backend s2{
>> .host = "190.120.90.2";
>> }
>>
>> sub vcl_init {
>> new vms = directors.round_robin();
>> vms.add_backend(s1);
>> vms.add_backend(s2);
>> }
>>
>> sub vcl_recv {
>> set req.backend_hint = vms.backend();
>> }
>>
>> sub vcl_hash {
>> hash_data(req.url);
>> if (req.http.host) {
>> hash_data(req.http.host);
>> } else {
>> hash_data(server.ip);
>> }
>> return(lookup);
>> }
>>
>>
>> Thanks,
>> Sreenath
>>
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc at varnish-cache.org
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20161125/551f5238/attachment.html>
More information about the varnish-misc
mailing list