LanCache - WindowsUpdate/Game caching

Discussion in 'General Software' started by elvis, Feb 10, 2021.

  1. Symon

    Symon Castigat ridendo mores

    Joined:
    Apr 17, 2002
    Messages:
    5,009
    Location:
    Brisbane QLD
    Unfortunately my lovely QNAP only allows containers to be pulled from the Docker hub, it won't pull directly from git unless I create a ubuntu in a container and pull from there. Might try that now.
     
  2. OP
    OP
    elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    45,081
    Location:
    Brisbane
    I don't use QNAPs, but can you point it to a docker-compose.yml file?

    Containers are customisable, and the image itself is only half the picture. A proper container manager needs to work with that.
     
  3. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Looks like you've answered all of it by yourselves. :)

    Yes, LanCache runs on an RPi4 perfectly now.
    No, you can't run LanCache and Pi-Hole natively together because, as said earlier, they both want to bind to port 53. The only reason you can run Pi-Hole and Unbound together is because you configure it to run Pi-Hole on port 53 and Unbound on 5335, then tell Pi-Hole that its upstream DNS (which is unbound) is on the loopback 127.0.0.1:5335

    My DNS path is: client -> LanCache:53 -> Pi-Hole:53 ->Unbound:5335 -> "Outside"(local routers then firewalls, etc)
     
    Last edited: Oct 7, 2021
    elvis likes this.
  4. Symon

    Symon Castigat ridendo mores

    Joined:
    Apr 17, 2002
    Messages:
    5,009
    Location:
    Brisbane QLD
    After a bit of hunting around there is an option to copy and paste the YAML code into the container generation thing. However it comes up with validation errors so won't accept it. From a brief search this appears to be a known QNAP issue.
     
    elvis likes this.
  5. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Could you post what your scripts are looking like, please?
    Have you done any monitoring with grafana?
     
  6. th3_hawk

    th3_hawk Member

    Joined:
    Jun 4, 2005
    Messages:
    2,517
    Location:
    Kilsyth 3137
    So I might have just bought another Pi and POE hat to add to the collection and try this out.... Now to go and 3D print another sled and tray for that last space in my 3D printed rack... If I get another Pi I will need to print a whole new unit ;)


    [​IMG]
     
    Symon likes this.
  7. th3_hawk

    th3_hawk Member

    Joined:
    Jun 4, 2005
    Messages:
    2,517
    Location:
    Kilsyth 3137
    I got impatient and pulled one of my other Pi's out of my arcade machine to tinker. It's seems to be working, although there is a couple of things I still need to sort (like getting lancache-DNS to auto start), but otherwise manually configuring only my computer to look at it for testing at the moment it appears to be working... sort of.

    Did you do any slicer settings with multiple IP's? I'm struggling to get speed >5MB/s either live or from the cache.

    EDIT1: Seems that is limited to Steam, Ubisoft is at least downloading new data at full speed, cache speeds to be tested next.
    EDIT2: Ubi started at about 25MB/s but has settled down to about 20MB/s. Concurrent downloads from the cache to different clients (on the same PC) seem to get that up to a max of 30MB/s, but I was expecting a little more (he says greedily).
    EDIT3: Switched to an SSD instead of a mechanical HDD seems to give me 30MB/s or so but I see CPU usage is still very low (under 20%) when serving from the cache. It's much higher when downloading new things, but still only up to 60% or so. Overlocking the Pi to 2GHz doesn't seem to help either.

    Am I reading correctly if, when looking at docker stats of Net I/O, if output is greater than input that the cache is working?

    Otherwise, If you're willing to share those scripts looks to be rather awesome.
     
    Last edited: Oct 10, 2021
  8. th3_hawk

    th3_hawk Member

    Joined:
    Jun 4, 2005
    Messages:
    2,517
    Location:
    Kilsyth 3137
    Day #2

    The issue really is always DNS
    I've been tearing my hair out trying to get the DNS container to load at boot. Setting it as a service and generally reading around all sorts of reports of people with the same issue for various and seemingly unrelated reasons, very few with solutions.
    The page I found talking about creating the service seems to not be quite right, I dropped the path information for ExecStart and Stop as that location isn't correct (not really sure what it should be). It still doesn't load on boot, but running the service manually does seem to work now.
    Looking into the log and it seems to talk about a lack of connectivity. BUT BUT BUT! I had a brain fart and turned on the wait for network connectivity at boot option in raspi-config and that appears to have solved the issue with multiple test re-boots now coming up with the service active and both containers running happily. WOOT!

    Speeds
    Now that the service seems to be settled I can look into performance a little more.
    Speeds are a little all over the place, sometimes I see ~15MB/s but then I've seen anything from 30 - 60MB/s. It doesn't appear to correlate with CPU load, especially when pre-cached downloads barely touch the CPU, but I've left the 2GHz overclock on for now. Maybe it's more about whatever it is I'm downloading and how those particular files are served up?? This is something I will have to monitor and see how it performs into the future. In any case, I'm back to using the 1TB 2.5" drive over USB 3.

    DNS Configuration
    Because I have my PiHoles and want to automate this across the network as transparently as possible while also keeping data reporting (what little Unifi allows anyway) intact I've added some unbound scripts to my PiHoles using this tool that I linked before. Testing first with the secondary Pi before deploying it to the primary one and it all appears to be working.


    I've walked into my Son's room and had him download a game from Epic that I had been using in testing. His machine has had zero changes made and points at my usual PiHoles, BAM 50MB/s transfer. Hell yeah.


    After all my tinkering and poking and screwing around, the summary is actually pretty short and is mostly a reflection of me knowing only *just* enough to be dangerous :p

    Summary of how I got there:
    1. Starting with a fresh install of Raspbian with all updates applied (as at 11/10/21)
    1a. Ensure wait for network connection on boot is enabled through raspi-config
    2. Mount an external storage device using fstab
    3. Install lancache for Raspberry Pi
    3a. Edit .env as needed and compose your docker containers
    4. Create a service to ensure Docker works at boot (noting that of all the listed steps all I needed was to create the .service file and enable it). <- As below from Blinky this shouldn't be needed.
    4a. Make sure it all works through a re-boot <- if not try a sudo docker-compose up -d --remove-orphans (as Blinky suggested)

    If this is your only DNS device you can now happily point your devices at it and away you go.

    In my case I run unbound/PiHole on two redundant Pi's so needed to create some rules to put on both:
    5. Download this scripting tool to make the rules
    5a. Edit the config file as needed and run the script as directed (I needed to install jq before I could use the tool).
    6. Copy/Move the files into the relevant unbound folder (for both my Pis) and restart unbound on both.

    7. Profit?
     
    Last edited: Oct 12, 2021
    Symon and Blinky like this.
  9. Symon

    Symon Castigat ridendo mores

    Joined:
    Apr 17, 2002
    Messages:
    5,009
    Location:
    Brisbane QLD
    You've done well there, I've given up trying to get that to work on my ubuntu box. I just manually execute the docker-compose command each time I reboot that machine, which isn't that often thankfully.
     
  10. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Just to come back to this for a minute, why did you make a step 4? Your docker service should already be running after a reboot. Were you getting nothing when you checked after a reboot?
    You should be able to query the docker service with $ sudo systemctl status docker and get a reply marked as active. Your two containers are taken care of within the yaml config using "restart: always"
    There was an issue previously with restarting the containers after an edit, which is why you should use $ sudo docker-compose up -d --remove-orphans
     
    th3_hawk likes this.
  11. th3_hawk

    th3_hawk Member

    Joined:
    Jun 4, 2005
    Messages:
    2,517
    Location:
    Kilsyth 3137
    That was one thing I wondered about yesterday so before I finished up and disabled the script and rebooted. Docker itself seemed to start but no containers were loaded so I re-enabled the script.

    For shits and giggles I tried again this morning on reading this with the same result.... up until I used the --remove-orphans switch. Now it's booting and the containers are loading like they should.

    Why oh why? There were zero edits that I remember, it's not like it's a detailed configuration file to begin with. In any case, I've updated the previous post to reflect this.

    Thanks for taking the time to respond.
     
  12. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Ah! Now it makes sense.
    So you would agree with me when I said;

    https://forums.overclockers.com.au/posts/18967330/
    To answer your question, I don’t know why, sorry; and when I discussed it privately with Justin neither did he at the time. Oddly enough, I have only ever had it happen with this RPi version.

    You should have ask in here, I might have been able to save you a headache. The only reason I know the solution is because I turned to Elvis for a fresh pair of eyes and when he expressed the command it had the extra switches of —remove-orphans which stood out, so I thought that might be it. Although as you say, there is not noticeable an active config change and the containers in question should be down at the time, if you were to make a change and as such should come up cleanly.

    I thought it was just my ignorance but when the dev doesn’t know, it makes me wonder how many RPi people are just giving up and moving on, which would be disappointing. :(
     
  13. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Under the grounds of "during the second cup of coffee", would you try something for me please?

    Edit your docker-compose.yml to change the condition of the restart statement to unless-stopped and then try to simulate the error again.

    Your new docker-compose.yml should look like this:

    Code:
    version: '3'
    services:
      dns:
        image: jrcichra/lancachenet-lancache-dns:latest  ## Pulling DNS server for arm
        env_file: .env
        ports:
          - ${DNS_BIND_IP}:53:53/udp
          - ${DNS_BIND_IP}:53:53/tcp
        restart: unless-stopped
    ##  sniproxy:
    ##    image: jrcichra/lancachenet-sniproxy:latest  ## Pulling Sniproxy for arm
    ##    env_file: .env
    ##    ports:
    ##      - 443:443/tcp
    ##    restart: always
      monolithic:
        image: jrcichra/lancachenet-monolithic:latest ## Pulling monolithic for arm
        env_file: .env
        ports:
          - 80:80/tcp
          - 443:443/tcp
        restart: unless-stopped
        volumes:
          - ${CACHE_ROOT}/cache:/data/cache
          - ${CACHE_ROOT}/logs:/data/logs
     
  14. OP
    OP
    elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    45,081
    Location:
    Brisbane
    Okie dokie some quick Docker 101 - here's how you get things to auto start.

    Check your instances:

    Code:
    # docker ps
    CONTAINER ID   IMAGE                             COMMAND                  CREATED       STATUS       PORTS                                                                      NAMES
    d488502d0328   lancachenet/monolithic:latest     "/bin/bash -e /init/…"   2 days ago    Up 8 hours   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   lancache_monolithic_1
    b5fb4cafdacd   lancachenet/lancache-dns:latest   "/bin/bash -e /init/…"   10 days ago   Up 8 hours   192.168.3.250:53->53/tcp, 192.168.3.250:53->53/udp                         lancache_dns_1
    
    Your Container IDs may differ, so check your own output. But I can check the restart policy of mine like so:

    Code:
    # docker inspect b5fb4cafdacd | grep -A3 RestartPolicy
    "RestartPolicy": {
       "Name": "always",
       "MaximumRetryCount": 0
    },
    
    I've modified mine previously, but you might have values like "no", "on-failure", "unless-stopped", etc. To set ALL of your containers to always start:

    Code:
    # docker update --restart always $(docker ps -q)
    
    Bit of Linux 101 trickery in there. The $(docker ps -q) command executes in a separate shell, and returns just the container IDs. That's then passed to "docker update" and it applies the config to all containers.

    If you've got other containers in there you don't want to apply the config to, just find their individual container IDs from "docker ps".
     
  15. th3_hawk

    th3_hawk Member

    Joined:
    Jun 4, 2005
    Messages:
    2,517
    Location:
    Kilsyth 3137

    Happy to try for you.

    I edited yaml, did docker-compose, reboot and both containers are up and working.
    Used the inspect command and both say unless-stopped now.
    Code:
    pi@raspberrypi:~ $ sudo docker inspect 6caef6024c7a | grep -A3 RestartPolicy
                "RestartPolicy": {
                    "Name": "unless-stopped",
                    "MaximumRetryCount": 0
                },
    
    Used Elvis command
    Code:
    # docker update --restart always $(docker ps -q)
    reboot, both came up, both now say always.

    edit yaml again back to 'always' so I don't forget next time I need to go in there. docker-compose. reboot again.
    Both containers up, both still say always...

    Seems I can't make the error happen again.

    For good measure added in a --remove-orphans and rebooted again. Still working.
     
  16. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Thanks.
    The change was mostly about using the different restart condition. "unless-stopped" seemed like a better choice than "always" to me.

    https://github.com/compose-spec/compose-spec/blob/master/spec.md#restart

    restart defines the policy that the platform will apply on container termination.

    • no: The default restart policy. Does not restart a container under any circumstances.
    • always: The policy always restarts the container until its removal.
    • on-failure: The policy restarts a container if the exit code indicates an error.
    • unless-stopped: The policy restarts a container irrespective of the exit code but will stop restarting when the service is stopped or removed.
    restart: "no"
    restart: always
    restart: on-failure
    restart: unless-stopped

     
  17. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Hmmm, I need to do something about the speed on my lancache server.

    Rocketing_Download.jpg
     
    Symon, th3_hawk and elvis like this.
  18. th3_hawk

    th3_hawk Member

    Joined:
    Jun 4, 2005
    Messages:
    2,517
    Location:
    Kilsyth 3137
    How do you survive??/s

    My first real test will be Vanguard, everything else is relatively tiny little updates which I personally don't tend to see because this machine is on all the time for work so things tend to happen in the background most of the time.
     
  19. OP
    OP
    elvis

    elvis Old school old fool

    Joined:
    Jun 27, 2001
    Messages:
    45,081
    Location:
    Brisbane
    I'm considering some Ethernet bonding on my home file server for the first time since the 100Mbit to 1GbE transition.
     
  20. Blinky

    Blinky Member

    Joined:
    Jul 4, 2001
    Messages:
    3,514
    Location:
    Brisbane
    Sorry, it wasn't meant to be an e-penis thing, it really was just a test. I had locked down the gateway router to ensure that nothing could go past 50Mbps so as not to affect the speed and had been running a few tests on the main part of the network. I don't actually game-at-all, I got the game as a freebie from the current Samsung sale. https://www.samsung.com/au/offer/ssd-farcry6-2021/
     

Share This Page

Advertisement: