<div dir="ltr">Hi folks. I am transitioning to v5 VCL, and the shard directors look useful. In our case, we have several products behind Varnish, so I create a bunch of directors:<div><br></div><div>    sub vcl_init {</div><div>        new product_a_director = directors.shard();</div><div>        product_a_director.add_backend(web01);</div><div>        product_a_director.add_backend(web02);</div><div>        product_a_director.reconfigure();</div><div><br></div><div>        new product_b_director = directors.shard();</div><div>        product_b_director.add_backend(web03);</div><div>        product_b_director.add_backend(web04);</div><div>        product_b_director.reconfigure();</div><div>    }<br></div><div><br></div><div>Then, later on in my vcl_recv, I have to make a bunch of decisions based on the host and URL to determine which set of backends to send the request to:</div><div><br></div><div><br></div><div>    if (req.http.host == "<a href="http://product_a.mydomain.com">product_a.mydomain.com</a>") {</div><div>        set req.backend_hint = product_a_director.backend();</div><div>    }</div><div><br></div><div>    if (req.url ~ "^/login.*") {</div><div>        set req.backend_hint = product_b_director.backend();</div><div>    }</div><div><br></div><div>In reality, there are thirteen directors for various products and product areas, which direct traffic to various combinations of the 15 backends to separate workloads or to route to servers with particular configuration.</div><div><br></div><div>It is important for us that traffic from a particular IP goes to the same backend in each director whenever possible, so do I have to use the manual "key" property of the shard director? That would change the above to:</div><div><br></div><div><div>    if (req.http.host == "<a href="http://product_a.mydomain.com">product_a.mydomain.com</a>") {</div><div>        set req.backend_hint = product_a_director.backend(KEY, product_a_director.key(client.ip));</div><div>    }</div><div><br></div><div>    if (req.url ~ "^/login.*") {</div><div>        set req.backend_hint = product_b_director.backend(KEY, product_b_director.key(client_ip));</div><div>    }</div></div><div><br></div><div>Is that the correct way to lock a client to a backend? I do not want to use session cookies, this should transcend sessions, so all traffic from one IP goes to the same backend (if healthy/available/possible).</div><div><br></div><div>Thanks,</div><div><br></div><div>Mark</div></div>