Join the community today
Become a Member

PHP-FPM [download server] - php file run very slow

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by babyshark, Feb 20, 2019.

  1. babyshark

    babyshark New Member

    20
    5
    3
    Jan 22, 2019
    Ratings:
    +7
    Local Time:
    10:05 PM
    Hi, first sorry for my english skill.

    I have problem. I build server for download file. Few week ago, all thing was ok. But now download file very slow processing, some time error (long time run php file).
    I try reboot server, download file is back to normal, but few hour later download file slow again.

    here my top command result:
    top screen.png

    all is ok, load average or % wa speed.

    try download file in direct link is ok (ex: http://myserv.com/data/file.zip)

    but download via php script is very slow (some time error)

    ex: http://myserv.com/download.php?file=abc

    here is my download.php method:
    PHP:
    <?php
    $file 
    '/path/to/files/photo.jpg';
    if (
    is_file($file))
    {
        
    sendHeaders($file'image/jpeg''My picture.jpg');
        
    $chunkSize 1024 1024;
        
    $handle fopen($file'rb');
        while (!
    feof($handle))
        {
            
    $buffer fread($handle$chunkSize);
            echo 
    $buffer;
            
    ob_flush();
            
    flush();
        }
        
    fclose($handle);
        exit;
    }
    ?>
    ah, when in "slow" time, try some php with only echo text function still slow too,
    mean link http://myserv.com/echo.php will run very slow too.

    So is there any wrong was there.
    I checked server running ok, no any program make overload cpu, or long time. but download via php file very slow.

    can help me this big problem.

    thank very much
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    1:05 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  3. babyshark

    babyshark New Member

    20
    5
    3
    Jan 22, 2019
    Ratings:
    +7
    Local Time:
    10:05 PM
    thank very much, I will try in your way.

    thanks again