title: PHP Amazon S3 Upload Speed
body: <p>I am using a <a href="http://undesigned.org.za/2007/10/22/amazon-s3-php-class/" rel="nofollow">PHP Amazon S3 Class</a> (which seems to be highly recommended and widely used) and have found that the speed of a file upload is extremely slow compared to if I use the command line <a href="http://s3tools.org/s3cmd" rel="nofollow">s3cmd</a> utility.</p>
  
  <p>For example, the same 20mb file took 2.8 seconds via s3cmd and around 54 seconds via php:</p>
  
  <p>Command Line:</p>
  
  <pre><code>s3cmd put archive.tar.gz s3://bucket
  </code></pre>
  
  <p>Output: <em>File 'archive.tar.gz' stored as s3://bucket/archive.tar.gz (23320623 bytes in 2.8 seconds, 8.07 MB/s) [1 of 1]</em></p>
  
  <p>PHP:</p>
  
  <pre><code>$time = time();
  
  $s3 = new S3('ACCESS KEY','SECRET KEY');
  $s3-&gt;putObjectFile('archive.tar.gz','bucket','archive.tar.gz');
  
  echo 'Done in '.(time()-$time).' seconds';
  </code></pre>
  
  <p>Output: <em>Done in 54 seconds</em></p>
  
  <p>Is this just something I have to accept if using PHP to upload to S3? Or is there a better way of doing this that I'm missing? I just can't see why there would be such a huge discrepancy in the upload speed and as I need to do this with much bigger files in the future, such slowness is going to be problematic.</p>