-4
  • Server : IBM X3630
  • CPU : 2x Intel Quad Core E5620 (8265 point)
  • RAM : 16GB DDR3
  • Hard Disk : 4x300GB SAS 15k
  • Bandwidth : 10 TB Uplink Port
  • Speed : 1 x 1000Mbps Full-Duplex

With above features my server's download speed is good. But when i try to upload a file, it is very slow. I tried 2 ways with 10 MB image file.

First way with file_get_contents():

<?php

$link = 'http://www.domain.com/testfile.jpg';
$start = time();
$size = filesize($link);
$file = file_get_contents($link);
$end = time();
$time = $end - $start;
$size = $size / 1048576;
$speed = $size / $time;
echo "Server's speed is: $speed MB/s";

?>

Result is: Server's speed is: 4.8631234169 MB/s and finished after 2-3 seconds. I think it's great for me!

Second way as normal file upload with php:

<?php
if(isset($_FILES['uploadedfile']['tmp_name']))
{
    $target_path = "upload/";

    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".$target_path.basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
}
?>

<!DOCTYPE html>
<html>
<body>

    <form enctype="multipart/form-data" action="" method="POST">
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>

</body>
</html>

This way important for me because of my clients upload files with this way. It should be fast!

Result for this way: Finished uploading in 53 seconds. It is so wretched speed!

I searched on net how increasing upload speed but i couldnt find anything. What should i do?

Bora
  • 93
  • 1
  • 3
  • 3
    Have you considered that your internet connection might be the bottleneck? – EEAA Feb 10 '15 at 09:04
  • Can users who downvoted the question leave a comment about reason!? – Bora Feb 10 '15 at 09:04
  • @EEAA No no! I tried to upload same file on different live website, uploading finished in 4-5 secs. – Bora Feb 10 '15 at 09:09
  • Is there any configuration on server or is this about completely data center? – Bora Feb 10 '15 at 09:10
  • What can you tell us more about the setup? What devices do you have sitting between you and the ISP? Routers, fiber converters etc? Are you also the receiving end or just sending? What do you know about the remote node? – JonC Feb 10 '15 at 15:56

1 Answers1

2

There are a lot of things it could be, so I almost commented rather than answered. I'd look at disk speed and php config. Specifically, the memory limit should be larger than your max upload size in your php config. This link is drupal-specific but may help.

Katherine Villyard
  • 18,510
  • 4
  • 36
  • 59