Hi,
1.

Is there any way to normalize host headers and other things to say to varnish 
not to cache the same content for different backend?
I want to use round robin director but after fetching the content I want to 
normalize the header and cache the content,
I would appreciate if you give me an example about this and how I can do it.

2.
I couldn't find any good example for directors-shard and xshard-key-string, I 
would appreciate if you could give example about this too.

Many Thanks
________________________________
From: varnish-misc 
<[email protected]> on behalf of 
Hamidreza Hosseini <[email protected]>
Sent: Sunday, August 1, 2021 4:17 AM
To: [email protected] <[email protected]>
Subject: Best practice for caching scenario with different backend servers but 
same content

Hi,
I want to use varnish in my scenario as cache service, I have about 10 http 
servers that serve Hls fragments as the backend servers and about 5 varnish 
servers for caching purpose, the problem comes in when I use round-robin 
director for backend servers in varnish,
if a varnish for specific file requests to one backend server and for the same 
file but to another backend server it would cache that file again because of 
different Host headers ! so my solution is using fallback director instead of 
round-robin as follow:

```
In varnish-1:
    new hls_cluster = directors.fallback();
    hls_cluster.add_backend(b1());
    hls_cluster.add_backend(b2());
    hls_cluster.add_backend(b3());
    hls_cluster.add_backend(b4());
    hls_cluster.add_backend(b5());
    hls_cluster.add_backend(b6());
    hls_cluster.add_backend(b7());
    hls_cluster.add_backend(b8());
    hls_cluster.add_backend(b9());
    hls_cluster.add_backend(b10());



In varnish-2:
    new hls_cluster = directors.fallback();
    hls_cluster.add_backend(b10());
    hls_cluster.add_backend(b1());
    hls_cluster.add_backend(b2());
    hls_cluster.add_backend(b3());
    hls_cluster.add_backend(b4());
    hls_cluster.add_backend(b5());
    hls_cluster.add_backend(b6());
    hls_cluster.add_backend(b7());
    hls_cluster.add_backend(b8());
    hls_cluster.add_backend(b9());


In varnish-3:
    new hls_cluster = directors.fallback();
    hls_cluster.add_backend(b9());
    hls_cluster.add_backend(b1());
    hls_cluster.add_backend(b2());
    hls_cluster.add_backend(b3());
    hls_cluster.add_backend(b4());
    hls_cluster.add_backend(b5());
    hls_cluster.add_backend(b6());
    hls_cluster.add_backend(b7());
    hls_cluster.add_backend(b8());
    hls_cluster.add_backend(b10());

```
But I think this is not the best solution, because there is no load balancing 
despite, I used different backend for the first argument of fallback directive,
What is varnish recommendation for this scenario?



_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to