azimjohn / jprq

join public router. quickly.
https://jprq.io
960 stars 141 forks source link

Slow download speed #217

Closed xzeldon closed 3 months ago

xzeldon commented 3 months ago

I have been able to run this software on my server. Thank you for the opportunity. Everything works fine except for one thing:

When I try to download a file, the download speed is very slow (300KB/s on average).

image

Is this an architectural limitation? Or is it a problem on my end? I have good internet speed on both the server and the client. I uploaded a local file to the same server (where jprq is hosted) at ~30MB/s and downloaded at about the same speed.

I am using the following NGINX configuration:

map $http_upgrade $connection_upgrade {
    default      keep-alive;
    'websocket'  upgrade;
    ''           close;
}

server {
    listen              80;
    server_name         hokage.su www.hokage.su;

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen              443 ssl;
    server_name         hokage.su www.hokage.su;
    ssl_certificate     /etc/letsencrypt/live/hokage.su/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/hokage.su/privkey.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location / {
      proxy_pass      http://localhost:3300;
      error_log       /var/log/nginx/jprq_web.log;
    }

}

server {
    listen              80;
    server_name         *.tunnel.hokage.su;

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen              443 ssl;
    server_name         *.tunnel.hokage.su;
    ssl_certificate     /etc/letsencrypt/live/tunnel.hokage.su/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/tunnel.hokage.su/privkey.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location / {
      proxy_pass       http://127.0.0.1:4320;
      proxy_set_header Host $host;
      error_log        /var/log/nginx/jprq_server.log;

      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;

      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
}

Of course, I ran it without NGINX as well, but the problem persisted. So presumably NGINX is not the weak link in this case.

azimjohn commented 3 months ago

This was intentional. As the server is actively used by a few hundred people, we had to limit the throughput.

Try removing this line before self-hosting https://github.com/azimjohn/jprq/blob/master/server/tunnel/tunnel.go#L141

xzeldon commented 3 months ago

So I comment this line, but seems nothing changes. image

azimjohn commented 3 months ago

I would drop Nginx altogether, jprq doesn't need a proxy, it is a proxy.

xzeldon commented 3 months ago

I don't know what happened, but the speed normalised. I didn't change any configurations, including disabling NGINX.

As for disabling NGINX, if you don't have a need for it, it is really worth disabling it. But in my case there are other web applications on the server and I need something like NGINX (or Caddy, Traefik etc.) to make these applications work correctly.

I guess the issue is solved.