VIP22: include backend connection in director lookup - varnishcache/varnish-cache GitHub Wiki

Ref: https://github.com/varnishcache/varnish-cache/issues/2765

Synopsis

In directors, the lookup and connection step are separate. For some scenarios, having an atomic "choose backend and return a connection" operation is required.

Why?

  • A director may return a backend which has max_connections reached by the time the actual connection is made
    • as a special case, a 100% correct last connections director is not currently possible
  • We need to (ab)use the retry mechanism as a workaround. If lookup of a backend and making a connection was an atomic operation, directors could guarantee to only hand out backends with a working connection.

How?

Ideas:

  • change the director paradigm away from implementing a resolve function to implementing a gethdrs function where resolution, making the connection and getting the headers all must succeed, with the option for the director to try other backends upon failure
    • seems to be the cleanest solution, but only works well in practice of all used directors implement gethdrs this way
  • make the result of the resolve function a list of backends to try in order