Download speed in nixos update is too slow

Nixos update is taking too long. 250MB is downloaded in 20 minutes.

Internet speed: ~80 Mb/s

Solved by adding mirror closer to my region:

nix = {
    settings = {
        # Cache configuration - optimized for Asia
        substituters = [
          "https://mirror.sjtu.edu.cn/nix-channels/store" # Shanghai Jiao Tong University - best for Asia
          "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC backup mirror
          "https://cache.nixos.org" # Official global cache
          "https://nix-community.cachix.org" # Community packages
          # "https://hyprland.cachix.org"
          # "https://aseipp-nix-cache.global.ssl.fastly.net"
        ];
    };
}

I’ve also added the following, though not sure how much this was helpful:

    # Download optimization
    http-connections = 128;
    max-substitution-jobs = 128;
    max-jobs = "auto";
5 Likes

Hi mabduqayum

So I’ve really been looking and have been unable to find a list of available mirrors.
As I’m also struggling a wee bit with variations in download speeds, but in europe instead.

Hopefully you or somebody else is willing to help me out.

Kind Regards

The official cache sits behind a pretty reasonable CDN: Maintainers:Fastly - Official NixOS Wiki. Unless you are in, say, China, you’re unlikely to get better performance from a mirror; that’s kinda the point of CDNs. Given how Europe-centric the community is, I also doubt being in Europe would imply poor cache performance :wink:

If you head to the website hosted on https://cache.nixos.org/, it gives instructions on how to ask for support if you’re running into issues.

I’ve noticed a couple of posts about people with poor performance, FWIW, and I noticed my downloads being slow too the last day or so. It’s quite possible this is a temporary thing, the wiki page also has a little warning that (theoretically invisible) changes are happening behind the scenes, so…

1 Like

I’m seeing slow downloads too. I am in the southern US and I am getting less than 1MB on a ATT GB fiber connection while updating. The strange thing is when I connect via Mullvad to pretty much anywhere, even Sweeden, I start getting 10-100MB downloads. I don’t even know where to look to troubleshoot the issue. ATT throttling? DNS? No clue.

There is definitely something wrong with either fastly or how the nixos infra configures it.

In Thailand my download speeds from cache.nixos.org are unbelievably slow. They drop into the 100 Kb/s range from time to time on a gigabit internet using the most popular internet provider here.
I am pulling +110 Mb/s from other CDNs.

It is not a short term problem. I am observing this since many months.

1 Like

The download speeds have been abysmal for a while here in Egypt too, except my home internet is pretty bad so I chalked it up to that.

That said, I am getting about 8 times as much bandwidth from the TUNA mirror halfway across the planet compared to cache.nixos.org.

% curl -LO https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store/nar/086vl6y57fmn098qalgb2wch04jgyrsyx7qy7vydrb4wzmn99mva.nar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  212M  100  212M    0     0  3319k      0  0:01:05  0:01:05 --:--:-- 3647k
% curl -LO https://cache.nixos.org/nar/086vl6y57fmn098qalgb2wch04jgyrsyx7qy7vydrb4wzmn99mva.nar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  212M  100  212M    0     0   396k      0  0:09:08  0:09:08 --:--:--  208k
1 Like

I also experienced very slow download speeds when Nix makes a huge amount of requests at once (I am in Europe with sometimes flaky but fast internet). My friend set up a Cloudflare proxy that helped me a lot

Just put this into your system config. Nix signs all packages, so there is no risk of a MIM attack

nix.settings = {
  substituters = lib.mkForce [
    "https://nixos-cache-proxy.cofob.dev"
  ];
};

CF should have servers everywhere in the world, so the ping should be equally good everywhere (no need to optimize for your continent). If you worry about putting some random domain as the main source of all your packages, you can set up the mirror yourself (it is free)

1 Like

Where did you hear that? NARs and .narinfo do get signed with a custom ed25519 signature and that’s checked after unpacking, but there’s no PGP in sight.

2 Likes

I didn’t know the exact algorithm, just assumed

That’s much faster than both TUNA and cache.nixos.org for me.

~% curl -LO https://nixos-cache-proxy.cofob.dev/nar/086vl6y57fmn098qalgb2wch04jgyrsyx7qy7vydrb4wzmn99mva.nar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  212M  100  212M    0     0  6643k      0  0:00:32  0:00:32 --:--:-- 6760k
1 Like

I have a Gigabit internet but the download speed I’m getting while updating are not great and very inconsistent. Here is the results of this diagnostics script I got from cache.nixos.org.