public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Frolkin <avf@eldamar.org.uk>
To: Simon Horman <horms@verge.net.au>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Julian Anastasov <ja@ssi.bg>,
	lvs-devel@vger.kernel.org, Wensong Zhang <wensong@linux-vs.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipvs: improved SH fallback strategy
Date: Wed, 25 Sep 2013 10:01:50 +0100	[thread overview]
Message-ID: <20130925090150.GC19768@eldamar.org.uk> (raw)
In-Reply-To: <20130925003033.GG26081@verge.net.au>

Hi,

> could you add some comments to the code or at least a description of the
> algorithm to the above the function.  The intent of original code may not
> have been obvious to the eye but this version certainly isn't obvious to
> mine.

Sure.  I have a bad habit of assuming that if I understand something,
then others automatically do too. :-)

The original code went through the table, starting at the same place as
the code without fallback and if that returned an unavailable
realserver, it offset the hash by one and repeated the lookup, then added
two, etc., up to IP_VS_SH_TAB_SIZE-1.  So the hash offset was 0,
1, ..., IP_VS_SH_TAB_SIZE-1.

The result is that if a server is down, all traffic destined for it
would fall back onto the next server in the list.

The new code also starts at the same place as the old code (offset 0),
but if that fails, it uses the same fallback strategy as the old code,
but the hash offset is now ihash, ihash + 1, ..., IP_VS_SH_TAB_SIZE-1,
0, 1, ..., ihash - 1, i.e., it starts at ihash instead of 0 and loops
around the table.  ihash could have been a random number, but choosing
it to be something based on the source IP and port (in which case it may
as well be the same hash [offset 0]) means that the behaviour will be
the same on different directors. 

This spreads the load of an unavailable server across the remaining
servers instead of just moving it to the next one in the list.

Hope that makes sense...

I'll submit a patch with a comment shortly.


Alex


  reply	other threads:[~2013-09-25  9:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23 11:51 [PATCH] ipvs: improved SH fallback strategy Alexander Frolkin
2013-09-23 19:42 ` Sergei Shtylyov
2013-09-24  9:32   ` Alexander Frolkin
2013-09-25  0:30     ` Simon Horman
2013-09-25  9:01       ` Alexander Frolkin [this message]
2013-09-25  9:26       ` Alexander Frolkin
2013-09-26  5:30         ` Julian Anastasov
2013-09-26 10:05           ` Alexander Frolkin
2013-09-26 20:05             ` Julian Anastasov
2013-09-27 10:06               ` [PATCHv2] " Alexander Frolkin
2013-09-27 19:20                 ` Julian Anastasov
2013-10-15  1:55                   ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130925090150.GC19768@eldamar.org.uk \
    --to=avf@eldamar.org.uk \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=wensong@linux-vs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox