Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
c169cc9c
Unverified
Commit
c169cc9c
authored
Jun 07, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document director layering and .resolve()
Also motivated by #3935
parent
d0ea1b67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
vcl-backends.rst
doc/sphinx/users-guide/vcl-backends.rst
+47
-0
No files found.
doc/sphinx/users-guide/vcl-backends.rst
View file @
c169cc9c
...
...
@@ -309,6 +309,53 @@ not to change the probe config if you do a lot of VCL loading. Unloading
the VCL will discard the probes. For more information on how to do this
please see ref:`reference-vcl-director`.
Layering
--------
By default, most directors' ``.backend()`` methods return a reference
to the director itself. This allows for layering, like in this
example::
import directors;
sub vcl_init {
new dc1 = directors.round_robin();
dc1.add_backend(server1A);
dc1.add_backend(server1B);
new dc2 = directors.round_robin();
dc2.add_backend(server2A);
dc2.add_backend(server2B);
new dcprio = directors.fallback();
dcprio.add_backend(dc1);
dcprio.add_backend(dc2);
}
With this initialization, ``dcprio.backend()`` will resolve to either
``server1A`` or ``server1B`` if both are healthy or one of them if
only one is healthy. Only if both are sick will a healthy server from
``dc2`` be returned, if any.
Director Resolution
-------------------
The actual resolution happens when the backend connection is prepared
after a return from ``vcl_backend_fetch {}``.
In some cases like server sharding the resolution outcome is required
already in VCL. For such cases, the ``.resolve()`` method can be used,
like in this example::
set req.backend_hint = dcprio.backend().resolve();
When using this statement with the previous example code,
``req.backend_hint`` will be set to one of the ``server*`` backends or
the ``none`` backend if they were all sick.
``.resolve()`` works on any object of the ``BACKEND`` type.
.. _users-guide-advanced_backend_connection-pooling:
Connection Pooling
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment