title: Limit number of parallel downloads per IP
body: <p>We have an Amazon S3 bucket which generates time limited web URLs using the following code:</p>
  
  <pre><code>define('WP_USE_THEMES', false);
  require 'wp-blog-header.php';
  require_once './sdk-1.5.3/sdk.class.php';
  require_once './sdk-1.5.3/services/s3.class.php';
  
  $FILENAME = $_GET['filename'];  
  
  S3GetFile($FILENAME);
  
  function S3GetFile($filename){
  
  if(is_user_logged_in()){
      $url = getS3SignedURL($filename);
      header('Location: '.$url);
  }else{
      $url = 'http://myurl.com/';
      header('Location: '.$url);
  }
  }
  
  function getS3SignedURL($filename){
      $s3 = new AmazonS3();
      $bucket = 'bucketname';
      $url = $s3-&gt;get_object_url($bucket,$filename,'2 minutes');
      return $url;
  }
  </code></pre>
  
  <p>So, that's the code. We're using <strong>AWSSDK for PHP</strong>. </p>
  
  <p>This is a membership site. We're having problems with some of the members doing parallel downloads of all the files from the server. The host keeps shutting us down citing heavy resource usage.</p>
  
  <p>I'm trying to figure out the best way to limit the number of simultaneous downloads <em>per IP</em> or <em>per user</em> (possibly both, because I would like to test out case scenarios). I'm checking the documentation as well, but help from some experts here as well if you know already.</p>
  
  <p>Many Thanks,
  Sachin.</p>