<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 20, 2011, at 8:51 AM, Don Schoeman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">

  

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  
  <div bgcolor="#ffffff" text="#000000">
    <font face="Arial">Hi all,<br>
      <br>
      Before I start digging in the Twisted code, I'd just like to bump
      this off you in case the solution is obvious...<br>
      <br>
      I have a lot of clients having permanent connections to my TCP
      server. These clients are devices that will buffer data if it
      can't connect to the server. I can see a possible problem in the
      future if/when for whatever reason there is downtime on my server
      or the network and all these devices start connecting and
      transmitting their buffered data once the server is back up,
      potentially causing server flooding.<br>
      <br>
      What would be a good area to start looking into preventing
      something like this from happening? My first thoughts are to
      simply limit an X number of new connections per minute (or per X
      seconds) and to simply immediately drop new connections if it
      exceeds that limit. (I'd probably implement this on Protocol
      level). Over time the connections should theoretically normalise
      as the buffered data on the devices are also limited.<br>
      <br>
      Of course it would be better to not allow the connections from
      being established in the first place if the limits are exceeded
      (will be great for DDOS protection), but I have a feeling that
      might be difficult to achieve.<br>
      <br>
      Any thoughts/tips or even links to examples?<br></font></div></blockquote></div><br><div>My suggestion would be "try it and see what happens". &nbsp;You may be surprised to find that your Twisted app deals with the load just fine. &nbsp;I've seen several applications for which this is the case.</div><div><br></div><div>If there really is an issue, a running system will give you a _lot_ more information about what the issue might be than a guess in advance :).</div><div><br></div><div>You may rest assured, however, that Twisted has all the APIs you will need to use to shed load, if that is in fact necessary; you can call stopListening() on the Port object that is currently accepting your connections, you can call stopReading() which will take it out of the reactor (but allow the listen queue to continue backing up); you can call pauseProducing() on any connection that is feeding you too much data.</div><div><br></div><div>Does this answer your question?</div><div><br></div><div><br></div></body></html>