librespeed / speedtest

Self-hosted Speed Test for HTML5 and more. Easy setup, examples, configurable, mobile friendly. Supports PHP, Node, Multiple servers, and more
https://librespeed.org
GNU Lesser General Public License v3.0
11.91k stars 2.16k forks source link

Download is very slow #494

Open kksse opened 2 years ago

kksse commented 2 years ago

Description Download is very slow

Server OS : Windows 2016 iis10 + php : 8.1.6

Network : 1000/1000M, Fiber

Client Windows 10 x64 Chrome

Screenshot 20220602142949 s

Computroniks commented 2 years ago

Have you ran any tests from other providers or repeated this test multiple times? Sometimes weird networking issues can cause problems and it is good to rule out any network issues.

kksse commented 2 years ago

The network is normal. The above test is run on the LAN.

kksse commented 2 years ago

install OpenSSL Troubleshooting

Computroniks commented 2 years ago

Hmm, what are your PHP settings at. I think that this is something to do with either the client, server or network as librespeed has been operating for a number of years without these sorts of issued

sorano commented 2 years ago

I'm seeing the same behaviour as OP, although on a different environment. The only common denominator I can see would be PHP 8.1.x Can anyone else confirm proper functionality with PHP 8.1.x?

OS: Ubuntu 22.04 nginx + PHP 8.1.2: image

Screenshot: image

Then iperf3 between the same devices just to rule out networking issues: image

namadori commented 2 years ago

Same issue here, Librespeed installer on al LXC container with Alpine Linux, PHP8.0.22 with php-fpm (following this guide. IPerf from the same container shows 980Mb while LibreSpeed stops at 12Mb.

Any suggestion on what to check?

prozbo commented 2 years ago

I had the same problem after upgrading Ubuntu 20.04 to Ubuntu 22.04, where is default and only PHP version 8.1. I additionally install php7.4 and after that everything works fine.

Cereal916 commented 1 year ago

Debian 11 PHP 7.4.30 5 mbps, download 163 mbps upload

other speed test sites have me at over 100 mbps download

Hoerli1337 commented 1 year ago

I am also testing again and encounter the same problems. LXC Container

Started to play with various parameters to maybe fix the error. Here is my config:

server {
    listen 80;
    listen [::]:80;
    access_log off;
    server_name speedtest.domain.de;
    return 301 https://$server_name$request_uri;
}

server {

        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        access_log off;

        server_name speedtest.domain.de;
        ssl_certificate /etc/letsencrypt/live/speedtest.domain.de/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/speedtest.domain.de/privkey.pem;

        root /var/www/speedtest;

    server_tokens off;
        gzip off;
        gzip_vary off;
        gzip_proxied any;
        gzip_comp_level 9;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_min_length 256;
        gzip_types text/plain application/rdf+xml application/atom+xml text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

        index index.php index.html index.htm;

        client_max_body_size 400M;

        location / {
           try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
           include snippets/fastcgi-php.conf;
           fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;
        }
}

nano /etc/php/8.1/fpm/php.ini

>> cgi.fix_pathinfo=0
>> memory_limit = 1024M

nano /etc/php/8.1/fpm/pool.d/www.conf

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
clear_env = no

nano /etc/php/8.1/fpm/pool.d/www.conf


pm = dynamic
pm.max_children = 120
pm.start_servers = 12
pm.min_spare_servers = 6
pm.max_spare_servers = 18

nano /etc/php/8.1/fpm/conf.d/10-opcache.ini

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
adonespitogo commented 1 year ago

I'm experiencing the same issue with apache and php 7.4.32 on a Trunas jail(vm). I did not change any significant apache/php config, everything is vanilla aside from copying speedtest sources to the document root dir.

cvclukes commented 1 year ago

I am noticing the same thing on Ubuntu 20.04.5 LTS and php 7.4.3. I haven't tweaked anything other than MTU being at jumbo packets. I'm still seeing a 500Meg/1Gig ratio though. I'm testing from a 2.5Gig/2.5Gig connection.

adonespitogo commented 1 year ago

Lucky for me, I have a running windows 7 as my server. I installed xamp there and I didn’t experience this issue that i had with bhyve in my truenas server.

Cereal916 commented 1 year ago

I was able to fix this by using the provided nginx settings.

adonespitogo commented 1 year ago

@Cereal916 can you provide a link to the nginx config you used to fix this?

luqmanmahama commented 1 year ago

Hey @sorano, maybe you need to check that your index.html and backend/ directory are in same directory and www-data has the write rights.

sorano commented 1 year ago

Hey @sorano, maybe you need to check that your index.html and backend/ directory are in same directory and www-data has the write rights.

No, my issue was I still had the old php7 fpm.sock in config. After changing to 8.1 all worked good again.

Hoerli1337 commented 1 year ago

Hi guys! I've been dealing with nginx and the speedtest for a while now. I think I have now found a possible solution.

After trying just about all the parameters in nginx, I couldn't see any improvement. So I went to the speedtest script and started to change the parameters there. For my small setup the following changes helped. In the speedtest_worker.js file the following has to be changed:

    time_ul_max: 20, // Set test duration manually - 20 seconds is good
    time_dl_max: 20, // Set test duration manually - 20 seconds is good
    xhr_dlMultistream: 6, // Set it fix to 6
    xhr_ulMultistream: 6, // Set it fix to 6
    time_auto: false, // Set this to false
    xhr_ul_blob_megabytes: 30, // Increased to 30 to better fill the cache
    garbagePhp_chunkSize: 5, // 100 is too much, with 10 the test runs better with 5 actually usable good
    enable_quirks: true, // must be set to false, so that the time values above can be used

Screenshot 2022-11-25 at 21-02-41 LibreSpeed Example

Tested with:

xiaojiedev commented 1 year ago

I also encountered this problem, enabling openssl extension for php solved it.

I think, that if you use a one-click script to install your web server environment, you will hardly have this problem. It is easy to miss when installing manually.

Tested with: Win-server 2012 nginx latest php8 latest HTTP non SSL

sliddjur commented 1 year ago

Is the docker-image affected by this?

Im getting much better results with iperf3 compared to web page. Testing between the same hosts. iperf3 gives me 200/200Mbps which is expected. librespeed container gives me 130/200Mbps, which is not expected

Environment is using only http and client and server are between an ipsec tunnel (lower than 1500 MTU) if that matters.

I see the container has

apachectl -M
...
 php7_module (shared)
...
root@a32114174e58:/etc/apache2# cat mods-enabled/php7.load
LoadModule php7_module        /usr/lib/apache2/modules/libphp7.so

docker image

root@nspeedtest:/opt/librespeed# docker images
REPOSITORY             TAG       IMAGE ID       CREATED         SIZE
adolfintel/speedtest   latest    a6292eb82e9d   12 months ago   478MB
adonespitogo commented 1 year ago

I think iperf test is not related to or does not connect to php scripts.

On Fri, Mar 31, 2023 at 12:11 AM sliddjur @.***> wrote:

Is the docker-image affected by this? Im getting much better results with iperf3 compared to web page. Testing between the same hosts. I see the container has

apachectl -M ... php7_module (shared) ... @.***:/etc/apache2# cat mods-enabled/php7.load LoadModule php7_module /usr/lib/apache2/modules/libphp7.so

docker image

@.***:/opt/librespeed# docker images REPOSITORY TAG IMAGE ID CREATED SIZE adolfintel/speedtest latest a6292eb82e9d 12 months ago 478MB

— Reply to this email directly, view it on GitHub https://github.com/librespeed/speedtest/issues/494#issuecomment-1490567500, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5JNRGKC4YYPDNX2WXYKVLW6WWBLANCNFSM5XT4N7QA . You are receiving this because you commented.Message ID: @.***>

fragtion commented 1 year ago

Was getting very slow Download speeds (<50Mbps) when trying to run linuxserver/librespeedtest:latest as a MikroTik container, even on an RB5009 and RB4011 which should both have ample CPU power...

For a moment I was really disappointed & thought I would need to find another solution than Librespeed...

Thanks to @Hoerli1337 's suggestions, I've settled on the following changes to /app/www/public/speedtest_worker.js , which seems to have mostly solved the problem for me:

    xhr_dlMultistream: 4,
    xhr_ulMultistream: 4,
    xhr_ul_blob_megabytes: 4,
    garbagePhp_chunkSize: 4,

I also changed in /app/www/public/backend/garbage.php :

    //$data = openssl_random_pseudo_bytes(1048576);
    $data = random_bytes(1048576);

These settings seem to saturate the 1Gbps interface for both up & down tests quite consistently, which satisfies my needs

I hope this helps someone else :)

pugson commented 1 year ago

thank you @fragtion that helped!

i went from sub-200Mbps tests to over 3.5Gbps speeds (capped by UDM-SE)

kingofkya commented 9 months ago

Try removeing http2 http/2 from your config it causes issues for me. After switching to http1.1 everything works great. It seams like its Chrome/Firefox was shoving the 4 requests into one stream, that then had infighting between threads.

loeeeee commented 6 months ago

I have encountered similar issues with download speed.

I was using LXC (Ubuntu 23.10), Nginx, and php8.2-fpm.

I set up the librespeed using the default config file comes with nginx.

I encountered 502 Bad Gateway for all of the PHP scripts in the librespeed, and Nginx is eating LOTS OF CPU power.

It turned out that the default scripts of Nginx in Ubuntu 23.10 says,

# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        # With php-cgi (or other tcp sockets):
#               fastcgi_pass 127.0.0.1:9000;
}

I forgot about the extact version, but after I changed the line,

        fastcgi_pass unix:/run/php/php7.4-fpm.sock;

into,

        fastcgi_pass unix:/run/php/php8.2-fpm.sock;

The download speed backs to normal.

BTW, plz do remember adding

        client_max_body_size 100M;

in your nginx config file. Otherwise, it would not work.

loeeeee commented 4 weeks ago

I have encountered similar issues with download speed.

I was using LXC (Ubuntu 23.10), Nginx, and php8.2-fpm.

I set up the librespeed using the default config file comes with nginx.

I encountered 502 Bad Gateway for all of the PHP scripts in the librespeed, and Nginx is eating LOTS OF CPU power.

It turned out that the default scripts of Nginx in Ubuntu 23.10 says,

# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        # With php-cgi (or other tcp sockets):
#               fastcgi_pass 127.0.0.1:9000;
}

I forgot about the extact version, but after I changed the line,

        fastcgi_pass unix:/run/php/php7.4-fpm.sock;

into,

        fastcgi_pass unix:/run/php/php8.2-fpm.sock;

The download speed backs to normal.

BTW, plz do remember adding

        client_max_body_size 100M;

in your nginx config file. Otherwise, it would not work.

For Ubuntu 24.04 LTS user, it should be php8.3-fpm