File: //usr/share/doc/varnish-6.0.3/html/phk/backends.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>What do you mean by ‘backend’ ? — Varnish version 6.0.3 documentation</title>
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Picking platforms" href="platforms.html" />
<link rel="prev" title="IPv6 Suckage" href="ipv6suckage.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="platforms.html" title="Picking platforms"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="ipv6suckage.html" title="IPv6 Suckage"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Varnish version 6.0.3 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Poul-Hennings random outbursts</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="what-do-you-mean-by-backend">
<span id="phk-backends"></span><h1>What do you mean by ‘backend’ ?<a class="headerlink" href="#what-do-you-mean-by-backend" title="Permalink to this headline">¶</a></h1>
<p>Given that we are approaching Varnish 3.0, you would think I had this
question answered conclusively long time ago, but once you try to
be efficient, things get hairy fast.</p>
<p>One of the features of Varnish we are very fundamental about, is the
ability to have multiple VCLs loaded at the same time, and to switch
between them instantly and seamlessly.</p>
<p>So imagine you have 1000 backends in your VCL, not an unreasonable
number, each configured with health-polling.</p>
<p>Now you fiddle your vcl_recv{} a bit and load the VCL again, but
since you are not sure which is the best way to do it, you keep
both VCL’s loaded so you can switch forth and back seamlessly.</p>
<p>To switch seamlessly, the health status of each backend needs to
be up to date the instant we switch to the other VCL.</p>
<p>This basically means that either all VCLs poll all their backends,
or they must share, somehow.</p>
<p>We can dismiss the all VCLs poll all their backends scenario,
because it scales truly horribly, and would pummel backends with
probes if people forget to vcl.discard their old dusty VCLs.</p>
<div class="section" id="share-and-enjoy">
<h2>Share And Enjoy<a class="headerlink" href="#share-and-enjoy" title="Permalink to this headline">¶</a></h2>
<p>In addition to health-status (including the saint-list), we also
want to share cached open connections and stats counters.</p>
<p>It would be truly stupid to close 100 ready and usable connections to
a backend, and open 100 other, just because we switch to a different
VCL that has an identical backend definition.</p>
<p>But what is an identical backend definition in this context?</p>
<p>It is important to remember that we are not talking physical
backends: For instance, there is nothing preventing a VCL for
having the same physical backend declared as 4 different VCL
backends.</p>
<p>The most obvious thing to do, is to use the VCL name of the backend
as identifier, but that is not enough. We can have two different
VCLs where backend “b1” points at two different physical machines,
for instance when we migrate or upgrade the backend.</p>
<dl class="docutils">
<dt>The identity of the state than can be shared is therefore the triplet:</dt>
<dd>{VCL-name, IPv4+port, IPv6+port}</dd>
</dl>
</div>
<div class="section" id="no-information-without-representation">
<h2>No Information without Representation<a class="headerlink" href="#no-information-without-representation" title="Permalink to this headline">¶</a></h2>
<p>Since the health-status will be for each of these triplets, we will
need to find a way to represent them in CLI and statistics contexts.</p>
<p>As long as we just print them out, that is not a big deal, but what
if you just want the health status for one of your 1000 backends,
how do you tell which one ?</p>
<p>The syntax-nazi way of doing that, is forcing people to type it all
every time:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">backend</span><span class="o">.</span><span class="n">health</span> <span class="n">b1</span><span class="p">(</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">8080</span><span class="p">,[::</span><span class="mi">1</span><span class="p">]:</span><span class="mi">8080</span><span class="p">)</span>
</pre></div>
</div>
<p>That will surely not be a hit with people who have just one backend.</p>
<p>I think, but until I implement I will not commit to, that the solution
is a wildcard-ish scheme, where you can write things like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">b1</span> <span class="c1"># The one and only backend b1 or error</span>
<span class="n">b1</span><span class="p">()</span> <span class="c1"># All backends named b1</span>
<span class="n">b1</span><span class="p">(</span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">)</span> <span class="c1"># All b1s on IPv4 lookback</span>
<span class="n">b1</span><span class="p">(:</span><span class="mi">8080</span><span class="p">)</span> <span class="c1"># All b1s on port 8080, (IPv4 or IPv6)</span>
<span class="n">b1</span><span class="p">(</span><span class="mf">192.168</span><span class="o">.</span><span class="mf">60.1</span><span class="p">,</span><span class="mf">192.168</span><span class="o">.</span><span class="mf">60.2</span><span class="p">)</span> <span class="c1"># All b1s on one of those addresses.</span>
</pre></div>
</div>
<p>(Input very much welcome)</p>
<p>The final question is if we use shortcut notation for output from
<a class="reference internal" href="../reference/varnishd.html#varnishd-1"><span class="std std-ref">varnishd</span></a>, and the answer is no, because we do not want the
stats-counters to change name because we load another VCL and suddenly
need disabiguation.</p>
</div>
<div class="section" id="sharing-health-status">
<h2>Sharing Health Status<a class="headerlink" href="#sharing-health-status" title="Permalink to this headline">¶</a></h2>
<p>To avoid the over-polling, we define that maximum one VCL polls at
backend at any time, and the active VCL gets preference. It is not
important which particular VCL polls the backends not in the active
VCL, as long as one of them do.</p>
</div>
<div class="section" id="implementation">
<h2>Implementation<a class="headerlink" href="#implementation" title="Permalink to this headline">¶</a></h2>
<p>The poll-policy can be implemented by updating a back-pointer to
the poll-specification for all backends on vcl.use execution.</p>
<p>On vcl.discard, if this vcl was the active poller, it needs to walk
the list of vcls and substitute another. If the list is empty
the backend gets retired anyway.</p>
<p>We should either park a thread on each backend, or have a poller thread
which throws jobs into the work-pool as the backends needs polled.</p>
<p>The pattern matching is confined to CLI and possibly libvarnishapi</p>
<p>I think this will work,</p>
<p>Until next time,</p>
<p>Poul-Henning, 2010-08-09</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">What do you mean by ‘backend’ ?</a><ul>
<li><a class="reference internal" href="#share-and-enjoy">Share And Enjoy</a></li>
<li><a class="reference internal" href="#no-information-without-representation">No Information without Representation</a></li>
<li><a class="reference internal" href="#sharing-health-status">Sharing Health Status</a></li>
<li><a class="reference internal" href="#implementation">Implementation</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="ipv6suckage.html"
title="previous chapter">IPv6 Suckage</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="platforms.html"
title="next chapter">Picking platforms</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/phk/backends.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="platforms.html" title="Picking platforms"
>next</a> |</li>
<li class="right" >
<a href="ipv6suckage.html" title="IPv6 Suckage"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Varnish version 6.0.3 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" >Poul-Hennings random outbursts</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2010-2014, Varnish Software AS.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.6.
</div>
</body>
</html>