<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
First off, I would like to thank Per Buer for pointing out that I am
off by a factor of 1000 in the following<br>
statements. I have corrected for that below so that my statements
are more clear. My mistake was in<br>
considering modern processors as 2 megahertz instead of 2 gigahertz.<br>
<br>
On 3/7/2011 1:52 PM, David Helkowski wrote:
<blockquote cite="mid:4D752966.7000203@sbgnet.com" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
A modern CPU can run, at most, around 10 million -assembly based-
instructions per second.<br>
</blockquote>
Make that 10 billion. The math I am using is 5 x 2 gigahertz.<br>
<blockquote cite="mid:4D752966.7000203@sbgnet.com" type="cite"> See
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://en.wikipedia.org/wiki/Instructions_per_second">http://en.wikipedia.org/wiki/Instructions_per_second</a><br>
A regular expression compare is likely at least 20 or so assembly
instructions.<br>
That gives around 500,000 regular expression compares if you are
using 100% of the<br>
CPU just for that. A reasonable amount of CPU to consume would be
30% ( at most ).<br>
So; you are left with around 150k regular expression checks per
second.<br>
</blockquote>
The correct numbers here are 500 million. A regular expression
compare more likely takes<br>
40 assembly instructions, so I am going to cut this to 250 million.
LIkewise, at 30%, that<br>
leads to about 80 million.<br>
<blockquote cite="mid:4D752966.7000203@sbgnet.com" type="cite"> <br>
Lets suppose there are 500 different domains. On average, you will
be doing 250 if/else<br>
checks per call. 150k / 250 = 600. </blockquote>
The new number is 80 million / 250 = 320k<br>
<blockquote cite="mid:4D752966.7000203@sbgnet.com" type="cite">That
means that you will get, under fair conditions, a max<br>
of about 600 hits per second.</blockquote>
320,000 hits per second.<br>
Obviously, no server is capable of serving up such a number.<br>
Just using regular expressions in a cascading if/then will work fine
in this case.<br>
My apologies for the confusion in this regard.<br>
<br>
What I can see is a server serving around 10,000 hits per second.<br>
That would require about 30x the number of domains. You don't really<br>
want to eat up CPU usage for just if/then though, so probably at
around 10x<br>
the number of domains you'd want to switch to a hash table.<br>
<br>
So; correcting my conclusion; if you are altering configuration for
5000<br>
domains, then you are going to need a hash table. Otherwise you are
going<br>
to be fine just using a cascading if/then, despite it being ugly.<br>
<blockquote cite="mid:4D752966.7000203@sbgnet.com" type="cite"> The
person asking the question likely has 500 domains running.<br>
That gives a little over 1 hit possible per second per domain. Do
you think that is an acceptable<br>
solution for this person? I think not.<br>
<br>
Compare it to a hash lookup. A hash lookup, using a good minimal
perfect hashing algorithms,<br>
will take at most around 10 operations. Using the same math as
above, that gives around 300k<br>
lookups per second. A hash would be roughly 500 times faster than
using if/else...<br>
</blockquote>
Note that despite my being off by a factor of 1000, the
multiplication still holds out. If you use<br>
a hash table, even with only 500 domains, a hash table will -still-
be 500 times faster. I still think<br>
it would be great to have a hash table solution available for use in
VCL.<br>
<blockquote cite="mid:4D752966.7000203@sbgnet.com" type="cite"> <br>
On 3/7/2011 1:35 PM, Per Buer wrote:
<blockquote
cite="mid:AANLkTinFt7ZSEms1s_7eNN1t_-3-bqDxJfEmGTf0oSS9@mail.gmail.com"
type="cite">
<div>Hi,</div>
<div><br>
</div>
On Sun, Mar 6, 2011 at 11:39 PM, AD <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:straightflush@gmail.com">straightflush@gmail.com</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;"> <br>
<div> what is the best way to run an instance of varnish
that may need different vcl configurations for each
hostname. This could end up being 100-500 includes to map
to each hostname and then a long if/then block based on
the hostname. Is there a more scalable way to deal with
this?</div>
</blockquote>
<div><br>
</div>
<div>CPU and memory bandwidth is abundant on modern servers.
I'm actually not sure that having a 500 entries long if/else
statement will hamper performance at all. Remember, there
will be no system calls. I would guess a modern server will
execute at least a four million regex-based if/else per
second per CPU core if most of the code and data will be in
the on die cache. So executing 500 matches should take about
0.5ms.</div>
<div><br>
</div>
<div>It might not make sense to optimize this. </div>
<div><br>
</div>
</div>
-- <br>
Per Buer, Varnish Software<br>
Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype:
per.buer<br>
Varnish makes websites fly!<br>
Want to learn more about Varnish? <a moz-do-not-send="true"
href="http://www.varnish-software.com/whitepapers"
target="_blank">http://www.varnish-software.com/whitepapers</a><br>
<br>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
varnish-misc mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a></pre>
</blockquote>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
varnish-misc mailing list
<a class="moz-txt-link-abbreviated" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>
<a class="moz-txt-link-freetext" href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a></pre>
</blockquote>
<br>
</body>
</html>