Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Keepalive not being used for upstream servers #202

Open
lostact opened this issue Jan 28, 2025 · 0 comments
Open

[Suggestion] Keepalive not being used for upstream servers #202

lostact opened this issue Jan 28, 2025 · 0 comments

Comments

@lostact
Copy link

lostact commented Jan 28, 2025

One of the reasons initial downloads when using lancache are slower than downloading the game directly on the client is that the client uses keepalive and for each request to the content servers it does not open a new connection and instead uses an already open connection and that saves time, while the current nginx configuration of lancache does not use keepalive.

This is specially important when the client does not use many concurrent connections like Xbox (both windows and console) and sony consoles. This problem can be partially solved by increasing slice size or having dynamic slice size based on launcher to reduce number of requests, but the better solution is to have keepalive.

Enabling keepalive for upstream connections in nginx requires 3 things (as far as I know):

  1. "upstream" blocks with a list of server ips or domains
  2. using the name of upstream block in proxy_pass
  3. these two directives:
proxy_http_version 1.1;
proxy_set_header Connection "";

Considering that we already have the domain names of upstream servers, we can define a map and generate a file (or files) containing upstream files and include them. upstream names can also be equal to domain name, nginx looks for upstream blocks then resolves domain if nothing was found. Here is an example:

map $http_host $upstream_name {
    hostnames;
    default $http_real_host;
    *.steamcontent.com steamcontent.com;
}

.
.
.

upstream steamcontent.com {
    keepalive 16;
    keepalive_timeout 5m;
    server cache5-fra1.steamcontent.com; # nearest server to us can be chosen
}
upstream download.epicgames.com {
    keepalive 16;
    keepalive_timeout 5m;
    server download.epicgames.com;
}
upstream gst.prod.dl.playstation.net {
    keepalive 16;
    keepalive_timeout 5m;
    server gst.prod.dl.playstation.net;
}

.
.
.

proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://$upstream_name$request_uri;

This requires a script that generates upstream blocks for each possible subdomain, which is a bit complicated. I have implemented a custom setup like this in my own server and it has improved initial download speeds drastically. Like to know your thoughts on this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant