A modern CPU can run, at most, around 10 million -assembly based-
instructions per second.
See http://en.wikipedia.org/wiki/Instructions_per_second
A regular expression compare is likely at least 20 or so assembly
instructions.
That gives around 500,000 regular expression compares if you are using
100% of the
CPU just for that. A reasonable amount of CPU to consume would be 30% (
at most ).
So; you are left with around 150k regular expression checks per second.
Lets suppose there are 500 different domains. On average, you will be
doing 250 if/else
checks per call. 150k / 250 = 600. That means that you will get, under
fair conditions, a max
of about 600 hits per second. The person asking the question likely has
500 domains running.
That gives a little over 1 hit possible per second per domain. Do you
think that is an acceptable
solution for this person? I think not.
Compare it to a hash lookup. A hash lookup, using a good minimal perfect
hashing algorithms,
will take at most around 10 operations. Using the same math as above,
that gives around 300k
lookups per second. A hash would be roughly 500 times faster than using
if/else...
On 3/7/2011 1:35 PM, Per Buer wrote:
Hi,
On Sun, Mar 6, 2011 at 11:39 PM, AD <[email protected]
<mailto:[email protected]>> wrote:
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?
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.
It might not make sense to optimize this.
--
Per Buer, Varnish Software
Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
Varnish makes websites fly!
Want to learn more about Varnish?
http://www.varnish-software.com/whitepapers
_______________________________________________
varnish-misc mailing list
[email protected]
http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
_______________________________________________
varnish-misc mailing list
[email protected]
http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc