Self-host your own internet speed test with LibreSpeed!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
internet speed tests are riddled with junk they include ads tracking java flash rip flash and a whole bunch of other stuff you don't really need so let's see if we can self-host our own speed test that claims to have no flash no sockets no java and no [Music] hey welcome back so i'm techno tim and today we're going to talk about self-hosting our own internet speed test and real quick if you have a question about anything in this video check out my live stream on twitch i spend a lot of time there answering a lot of your questions so if you need some help feel free to stop in and say hello and another thing thanks ahead of time for the likes and comments because it lets me know if i'm on track so let's get into it internet speed tests traditionally have been slow clunky and inaccurate most of the time they're chock full of ads and tracking and traditionally a lot of them have used plugins that are now deprecated to measure your internet speed i mean who needs those plugins now when most of the time our browsers can handle it on its own and then i started to think about who needs these websites anyway and that's when i started to search for a self-hosted option i stumbled upon an open source project called library speed so libre speed is an open source self-hosted speed test option that you can host inside of your own network it's based on javascript xhr and web workers so it doesn't require any additional plugins from the browser the nice part about it being a self-hosted option is that you can use it to test any device in your network locally but you also have the option to host it publicly too if you like and it also has a lot of the features that the public speed tests have things like upload speed download speed ping and jitter as well as sharing your results with others if you like now all of that is optional and configurable and i'll show you how to do that here in a little bit and the way we're going to set this up today is using docker and then move on to kubernetes i'll walk through how to set this up with docker and then i'll show you how to set it up in rancher and if you're not familiar with brancher rancher is just an easy way to get kubernetes which then gives you containerization and if you need help setting that up i've got a complete tutorial that'll walk you through setting up docker rancher and kubernetes in just a couple of minutes but if you don't want to do all that we'll cover docker too and so let's get into it so the source for our docker image is going to be linux server.io they build and maintain docker images for a lot of my favorite services and they've got great documentation too and the other nice thing about linux server is they have a common api for all of their docker images and you can see that here while we're configuring our docker container so if you're using plain old docker we'll cover that here but if you're using rancher we'll translate this to a rancher deployment or a kubernetes deployment here in a second but if you're using docker you'll run a daca run as a daemon then we're going to name this container librespeed then we're going to set some environment variables of puid and pgid and we set these for permissions and they're really easy to get all you have to do is remote into your server that's running docker and type id and then you'll want to use the id and the group that you use to run docker so in my case on my test machine it's 1000. next is tz for time zone we'll skip over the next environment variable and talk about databases first with libre speed you can store your results and you can store those results in different types of databases you can choose sqlite postgres or mysql and if you choose mysql or postgres you'll need to set a username and a password environment variable too so that's where this password one comes in but in our case we're going to use sqlite which is the embedded database and this parameter is optional and it will use this if you don't specify anything but you'll see that here in a second the next environment variable is custom results and that's whether or not you want to use a custom results page i think we'll opt out of that one for now and then p is for publish or our ports in this example they expose port 80 from the container to the outside of port 80 as well and we'll change that here in a little bit and v is for mounting our volume so in this example we'll have a path on our host that's mounted to a path in the container so the path on the host is on the left side and the path within the container is on the right side and that's because this is the staple application and it needs to write some data the next flag is restart unless stopped and this helps restart the container if something goes wrong and the last piece is our registry and it looks like they're using github's new registry instead of docker's registry and if you wanted to spin this up with plain old docker you would just paste that command and within seconds you would have library speed running on this machine but let's move on to rancher so in your rancher server you'll want to go to global cluster and their default cluster and then we'll go into the cluster that we created once you're here in workloads we'll want to deploy a new workload so we'll click deploy and now we're going to translate those docker commands we talked about earlier to a rancher or kubernetes deployment so here we'll name our kubernetes deployment and we'll name it librespeed next we want to set our image and that's right down here so our docker image is going to be this value here and you can keep the namespace to default or whatever namespace you use for your workloads next let's set our environment variables so puid and pgid we determined were 1000 and if you need that skip back about a minute or two next we'll set tz or timezone and mine is america chicago and then i'm going to opt out of the rest of the environment variables because this works fine without it i'm not going to use an external database and i don't really see the difference between the custom results and the default results so we can skip onto volumes next we'll expand volumes and then we'll see this fly out of different volume types now if you're using a single node in a single agent you've done the docker install and you don't have any more agents you can pick by mount a directory from a node and that will work fine if you only have one node but if you have more than one node you want to set up a persistent volume claim and i won't go into detail about how to set that up but if you're interested you could set up something like longhorn or nfs for your storage class and i've got a video on longhorn if you're interested in that but for the sake of this machine this is a single node so i'm gonna do by mount a directory from a node and here we can name our volume this can be anything really so i'm just naming mine libre speed next we'll set the mount point within the container and that's right here that slash config next we'll set the path on the node so we'll need to remote into that machine and create a folder for the path so i remoted into my server and i created a directory called librespeed and then in there i created a folder called config and then i cd into there so this is the path we're going to write to from our library speed container so we'll copy and paste this and then we'll paste it here so the next thing we'll need to take care of is our port mapping that's right here so in kubernetes we have a lot of options for port mapping now if we were running this in a cluster typically we would create an ingress to allow that traffic inside of these pods or in this case this one pod and if you know what i'm talking about you should probably create an ingress for this but if you're running this with a single node we can do this with host port and what this will do is map a port from the container to the host and we do it like this so let's add a port we'll name the port libre speed then we'll publish the containers port so the container exposes port 80 so we'll put 80 here to the host port which is this server to a port of your choosing and i'm going with thirty thousand one here that's because i know that these ports aren't gonna be used by other services but you'll wanna pick one that's not being used by either your containers that are running already and other services in general but the thirty thousand range is usually a pretty safe bet and before we spin that up we'll change one more thing we'll go into scaling and upgrade policy so since we chose host port we're going to need to set this to kill all pods then start new that's because we can't spin up another pod on that same port while the other pod is still active and so we'll choose kill all pods then start new then we can click launch and we can see it spun up already so let's go on to our speed test and if we go out to our speed test here it is so libre speed speed test so we have the option to start it we can see we have ping and jitter download upload and then a link to the source code and if we click start we can see it's already running a speed test now you might be thinking to yourself oh i don't have gigabit internet and i hate to break it to you you didn't get a speed upgrade that's because it's a test between the server and yourself and in this case the server is in kubernetes or docker and the client is me on my machine so really this was testing our gigabit ethernet which is totally fine and actually i think it's a feature i got roughly gigabit you can see my ip address which is a private ipv4 ip address you can see my ping was around one millisecond jitter was eight hundredths of a millisecond and then we actually have a link to our results so we click here it copies it to our clipboard and if we go to that url we can see our results so that's pretty awesome so back to the speed test we can actually configure this if we like personally i like this default theme but we can customize it they include some templates that we can swap out and i'll show you how to do it so if we go back to a rancher or docker server and we go inside a config and we do an ls now we should see that we have some files and in here you can see a www folder so let's cd into there and then do an ls and we can see here we have a bunch of files along with our index.html so our index.html is being loaded now but we could swap them out for these other examples so let's try that real quick so let me show you how this works first the first thing i'm going to do is actually move or copy this index.html to index.html.back so what this did was actually rename my index.html to index.html.back so that means i don't have an index.html anymore and you're right and if i refresh this and we see an error here albeit it's a 403 because it can't read the index.html but either way we see an error and so if we want to try one of these other examples all we need to do now is copy that example to our index.html so let's check out this example multiple servers full.html so what i do is do a copy example multiple servers full.html to index.html if we run that and run an ls we should now see we have an index.html and so if we refresh this now we see that full example and so this has an example that's actually pointing at an external server outside of your network and you can see this must be a libre speed demo server pointed at some server in helsinki so if we click start now we're testing our internet from this client to that server and you can see after running this test i'm getting around 140 megabits down and 51 megabits up and so that's really cool let's check out another example so let's do that same thing but with the pretty version refresh this page and now we have the pretty version it doesn't look too pretty to me maybe they mean minimal i don't know but let's run our speed test again and we can see our results and what if we just wanted a progress bar so let's try the progress bar and refresh now we have a progress bar and here's our results so this is really cool we can run a speed test internally and we can point it at external servers if we want the cool thing about running this internally is that because it's hosted internally we can access this from any device with a web browser so if you want to test your wireless network speed save with your phone you can do that very easily by going to this address and that cuts out the trip to the internet that you used to make by running a speed test on your phone so all we'll need to do is go to that address on your phone and we can see here we have our speed test we can click start and so this is testing from my phone to my access point to this doctor container and you can see i'm getting around 200 megabits per second and the download is around 115 megabits per second and you can see i have a ping of three milliseconds and a jitter of around seven milliseconds which that's pretty awesome i've never done a speed test on my phone directly to my access point but this is just one example of one touch point within your home just think you can do this with tablets xbox your playstation not your apple tv because they don't have a browser but other smart tvs that have browsers or really any device in your home that has a browser and the cool thing is it's not making that trip over the internet to someone else's server but if you do want to make that trip over the internet to your own server that's where this gets really cool too because you can actually host this externally if you like you can have your very own publicly hosted speed test you could host this in the cloud with aws google azure digitalocean anyone or you get to self-host it and expose it to the cloud so that you can get to it on the go you have a ton of options with this and that's part of the benefit of running something open source and self-hosting it is that you can customize and tailor this to your needs and i have some videos on exposing internal services publicly but that's out of scope for this and so what do you think of librespeed what do you think about hosting your own speed test how much utility do you think there is hosting your own speed test internally and testing it with internal devices let me know in the comments below and if you ran into any problems or have any questions about this video or any of my videos hop in my twitch stream and let's figure it out so thanks so much for watching and until next time stream on my friends and turn it into um create a service and a yaml file and try deploying it that way through coop control because then you'll start to realize oh like this is really powerful like i can have you know and you'll start to realize that a lot of the ammo for your services it's all copy pasta anyways it's coffee pasta replace a name replace an ingress maybe maybe a namespace doubt it uh and maybe a couple variables the rest is copypasta and then so then if it's copypasta you can go coug control apply whole entire folder and if you could do coop control you know dash f or a coupe control apply dash f to a folder i mean you just totally spun out however many services are are in that folder and you can spin up your whole entire infrastructure like that and you're like oh i am that didn't work had a typo in one file coupe control delete dash f point to the folder and and just totally burn down the whole entire environment
Info
Channel: Techno Tim
Views: 39,228
Rating: undefined out of 5
Keywords: LibreSpeed, speed test, self hosted, technotim, docker, rancher, kubernetes, k8s, k3s, selfhosted, homelab, open source, opensource, internet speed test, network speed test, javascript, xhr, techno tim, containers, containerization, upload, download, ping, jitter, open speed test, open speed test alternative, enterprise speed test, vpn speed test
Id: FWhsEsh1P3Y
Channel Id: undefined
Length: 14min 50sec (890 seconds)
Published: Sat Jan 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.