🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
6 messages
6 total messages Started by Eric A. Hall Tue, 31 Jul 2001 22:49
rate-limiting peers
#53577
Author: Eric A. Hall
Date: Tue, 31 Jul 2001 22:49
26 lines
2264 bytes
Let's say that I have a peering session which has a lot of bandwidth but
which also has a lot of latency, and I also have a couple of secondary
peers with a lot of bandwidth but very low latency. If I am wanting to
prevent the secondary peers from becoming my primary peers, could I
introduce an artificial TCP rate limit on the secondaries to force them to
stay behind?

For example, if the secondaries had a bunch of articles, they would send
the ones they could, until the primary had caught up (or passed them), at
which point I would start rejecting articles from the secondaries (I got
the other articles from the primary during the burst). With a bit of
tweaking I could probably tuned this so that I was only getting localized
feeds from the secondaries, while getting 80% from the primary.

One problem I can see with this is that whenever the primary goes bye-bye,
the secondaries would be sending everything, and would have to jam the
feed during this period.

So things would be rough when the primary failed, but other than that,
anything else wrong with this approach?

-- 
Eric A. Hall                                        http://www.ehsco.com/
Internet Core Protocols          http://www.oreilly.com/catalog/coreprot/
Re: rate-limiting peers
#53581
Author: Curt Welch
Date: Wed, 01 Aug 2001 05:23
82 lines
5347 bytes
"Eric A. Hall" <ehall@ehsco.com> wrote:
> Let's say that I have a peering session which has a lot of bandwidth but
> which also has a lot of latency, and I also have a couple of secondary
> peers with a lot of bandwidth but very low latency. If I am wanting to
> prevent the secondary peers from becoming my primary peers, could I
> introduce an artificial TCP rate limit on the secondaries to force them
> to stay behind?

yes.

> For example, if the secondaries had a bunch of articles, they would send
> the ones they could, until the primary had caught up (or passed them), at
> which point I would start rejecting articles from the secondaries (I got
> the other articles from the primary during the burst). With a bit of
> tweaking I could probably tuned this so that I was only getting localized
> feeds from the secondaries, while getting 80% from the primary.

One way this is done is have your secondaries run a delayed feed.  Many
servers can do that.  They simply hold the articles for a few minutes
before they try offering them to you - in effect introducing an artificial
latency in order to allow your high latency  cheap link (sat feed etc.) to
get the articles to you first.

> One problem I can see with this is that whenever the primary goes
> bye-bye, the secondaries would be sending everything, and would have to
> jam the feed during this period.

Another way to force the delay from your side is to limit the incomming
bandwidth of your secondary feeds to some constant amount.  This is
something I've just started playing with.  Not too sure how well it works
yet in practice.

If you normally get everything from your primary, and the secondary are
just for backups or for the few articles that were lost for some reason,
then if they are beating your primary feed, and sending you too much stuff,
their bandwidth usage will go up.  When they hit the limit, it will force
them to start to backlog, and the backlog will then stabilize at the point
where what they are sending you matches the bandwidth limit you set.

If your primary goes down, you don't get hit with a big increase in
bandwidth usage from your secondary feeds, because they were already
crusing at their limits (assuming they were beating you already).  But
because they are now having to send you a lot more, they will backlog even
further. When the primary comes back, the missing gap will still be filled
in from the secondaries, but slowly.  How well it works depends a lot on
where you have that bandwidth limit set and how long those secondary feeds
will hold a backlog for you before they start to drop articles.

The disadvantage of this system is if you set the bandwidth limit too low,
then the secondary will backlog until it reaches it's limit, and start to
drop articles.  That normally sucks because it just means you have added a
multiple hour delay into the system for no good reason.

> So things would be rough when the primary failed, but other than that,
> anything else wrong with this approach?

You didn't really expalin what algorithm/logic you were going to do to slow
down the peers.  Rate limit in bytes per second?  articles per second sent?
articles per second offered? what?

I think any of those options would tend to have the same danger I talked
about with the banndwidth limiting (i.e rate limit bytes per second).

I guess another more complex way to do this is to look at the articles
beeing offered by the primary feeds and every time you decline the offer
because one of your secondary feeds sent it to you first, you would record
that fact.

You could then slow down the secondary using one of the rate limiting
options based on how many articles it was pusing in front of your primary.
That way, if the seconday started sending you lots of stuff that the
primary for some reason was never offering you, the system wouldn't slow
down the seconday just because it was sending so much.  It would only slow
it down if it was sending too much of the wrong stuff...

The way my server is structured I could try implementing that idea...
Hum...

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: rate-limiting peers
#53589
Author: Eric A. Hall
Date: Wed, 01 Aug 2001 15:29
31 lines
2607 bytes
> You didn't really expalin what algorithm/logic you were going to do to
> slow down the peers.  Rate limit in bytes per second?  articles per
> second sent? articles per second offered? what?

TCP rate-limiting, either by restricting rwin, or by stretching the ACKs
so that the delay is artificially high. There are different ramifications
for those two approaches, in particular wrt feed type.

> You could then slow down the secondary using one of the rate limiting
> options based on how many articles it was pusing in front of your
> primary. That way, if the seconday started sending you lots of stuff
> that the primary for some reason was never offering you, the system
> wouldn't slow down the seconday just because it was sending so much.
> It would only slow it down if it was sending too much of the wrong
> stuff...
> 
> The way my server is structured I could try implementing that idea...
> Hum...

Probably easier to implement delay timers on a per-peer basis, since you
will probably only have direct access to rwin, and you may have trouble
changing the rwin on a per-peer basis if you only have a single listener.
But yeah, it would be nice to have sliders for "use x bandwidth" on a
per-peer basis, combined with a weighted scheme for changing the usage
based on external conditions.

-- 
Eric A. Hall                                        http://www.ehsco.com/
Internet Core Protocols          http://www.oreilly.com/catalog/coreprot/
Re: rate-limiting peers
#53598
Author: Curt Welch
Date: Wed, 01 Aug 2001 23:16
39 lines
3272 bytes
"Eric A. Hall" <ehall@ehsco.com> wrote:
> TCP rate-limiting, either by restricting rwin, or by stretching the ACKs
> so that the delay is artificially high. There are different ramifications
> for those two approaches, in particular wrt feed type.

Ugh, don't strech the ACKs.  You just run the risk that the sender will
waste bandwidth re-transmitting and force them to hold the old packets in
their buffers wasting memory.  Just ack it and tell them you don't want
more with the rwin.  But hey, why are you talking TCP protocol hacks
anyway?  This stuff would normally just be done at the application level
and at that level, all you have to do is stop reading.  The TCP/IP stack
takes care of the rest. It is a flow-controled protocol.

> Probably easier to implement delay timers on a per-peer basis, since you
> will probably only have direct access to rwin, and you may have trouble
> changing the rwin on a per-peer basis if you only have a single listener.
> But yeah, it would be nice to have sliders for "use x bandwidth" on a
> per-peer basis, combined with a weighted scheme for changing the usage
> based on external conditions.

I have bandwidth limiting on a per-peer level (across multiple NNTP
connections) already in my server.  It's easy to do since all the
connections are serviced by a single processes.  You just calculate the
bandwidth and when it gets too high, you stop reading.  You re-check every
second until the bandwidth drops below the requied level and then read
again.  Makes for dead flat MRTG graphs.

I can set bandwidth limits for both incoming feeds and outgoing feeds.  And
I've just added an intersting little hack to limit my outgoing feed to a
peer based on a multiple of what they send me.  So I can limit my outgoing
data to any peer to be 2x what they send me for example.  I also have min
and max values associated with that system as well so I'll always be
willing to send them somehing even if they aren't sending me anything etc.
Fun stuff...

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Re: rate-limiting peers
#53600
Author: Eric A. Hall
Date: Wed, 01 Aug 2001 23:32
37 lines
2889 bytes
> Ugh, don't strech the ACKs.  You just run the risk that the sender
> will waste bandwidth re-transmitting and force them to hold the old
> packets in their buffers wasting memory.

End systems tend to stabilize around RTT pretty quickly. The benefit of
this particular hack is that it makes command-response activity take
longer (as long as you want), but without affecting throughput during bulk
transfers. EG, I can have a secondary on a long pipe so that commands take
longer to ACK, but when there is a bulk transfer (such as a backlog to be
cleared) then there is still a lot of pipe that can be filled when
necessary.

This is the opposite of just shrinking rwin, where command-response still
goes fast but bandwidth is limited when you really need it.

Stretching ACKs is a pretty neat hack. It lets you turn every connection
into a satellite link (not common but in this particular scenario it may
be very useful). Not at all harmful either.

It probably wouldn't work exactly right without a participating control
application also slowing down the response rates.

> This stuff would normally just be done at the application level
> and at that level, all you have to do is stop reading. The TCP/IP
> stack takes care of the rest. It is a flow-controled protocol.

Yeah, but I am looking for ways to control it on demand. I can tweak rwin
and ACK delay from an external box. Turning dials, flipping switches,
makes for a pretty responsive environment.

It's just an option I'm thinking about at the moment.

-- 
Eric A. Hall                                        http://www.ehsco.com/
Internet Core Protocols          http://www.oreilly.com/catalog/coreprot/
Re: rate-limiting peers
#53599
Author: Curt Welch
Date: Thu, 02 Aug 2001 00:13
78 lines
4941 bytes
"Eric A. Hall" <ehall@ehsco.com> wrote:
> > Ugh, don't strech the ACKs.  You just run the risk that the sender
> > will waste bandwidth re-transmitting and force them to hold the old
> > packets in their buffers wasting memory.
>
> End systems tend to stabilize around RTT pretty quickly. The benefit of
> this particular hack is that it makes command-response activity take
> longer (as long as you want), but without affecting throughput during
> bulk transfers. EG, I can have a secondary on a long pipe so that
> commands take longer to ACK, but when there is a bulk transfer (such as a
> backlog to be cleared) then there is still a lot of pipe that can be
> filled when necessary.

Ok, I can see how that might work for some things.  Be we are talking NNTP
feeds here (aren't we?)

NNTP feeds use CHECK/TAKETHIS commands sent as a large batch.  It's not one
command per packet.  They did this just to get around the problems of
latency.  If you leave rwin open and slow the ack, you will still get a
rwin full (32KB?) of check commands and the feed isn't going to slow down
at all.

Creating artificial latency in the TCP connection will make very little
difference in bandwidth used for a NNTP streaming feed - until you push the
latency out far enough that the rwin is filling up and they have to wait
for acks to send more.  I guess that works as long as the receiving side
doesn't have logic to increase the rwin size to make up for that.

> This is the opposite of just shrinking rwin, where command-response still
> goes fast but bandwidth is limited when you really need it.

Well, you don't just set a low max value for rwin, that's stupid as well.
That slows down the connection but it does it simply by make it less
efficient.

rwin (I hope I'm not confused here), changes dynamicaly as the receive
buffer fills up.  If the application doesn't read the data out of the TCP
stack, the rwin drops to 0 and the sending side simply stops sending.  When
the application reads, the receivng side ACKs the larger rwin and data
flows again.

TCP is flow controled and works fine.  If you want your application to
limit the bandwidth, just don't read the data any faster than you want the
other side to send it.  Don't "break" TCP just to slow it down.  That's
like shooting one of your tires out with a gun because you were going too
fast instead of just taking your foot off the gas.

> Stretching ACKs is a pretty neat hack. It lets you turn every connection
> into a satellite link (not common but in this particular scenario it may
> be very useful). Not at all harmful either.

Nore is it useful in my mind for doing anything besides simulating a sat
link.

> It probably wouldn't work exactly right without a participating control
> application also slowing down the response rates.
>
> > This stuff would normally just be done at the application level
> > and at that level, all you have to do is stop reading. The TCP/IP
> > stack takes care of the rest. It is a flow-controled protocol.
>
> Yeah, but I am looking for ways to control it on demand. I can tweak rwin
> and ACK delay from an external box. Turning dials, flipping switches,
> makes for a pretty responsive environment.
>
> It's just an option I'm thinking about at the moment.

Ok, I can see where if that's all you can do, then that might be an option
to play with.  That's fine.  You have to work with what you have control
over.

If you can't get access to the gas pedal, then sometimes you just have to
shoot the tires out. :)  Maybe it will work.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads