How I Built My Own Internet Speed Monitor

…using a Raspberry Pi, Docker, Python and Apache Superset

Daniel Sharp
Applied Data Science
4 min readMar 15, 2021

--

I’ve recently been having issues with my internet either being really slow, randomly dropping out, or not working at all — sound familiar?

To figure out if it was an issue with the internet service provider, I set up a monitor to routinely run a speed test and log the results.

It was also a perfect opportunity to try out Apache Superset - an open source dashboarding tool with a drag-and-drop interface!

📦 What I needed

✏️ Code — follow the instructions in the README file to run locally

🍓*🥧 A Raspberry Pi 4 Model B with 8GB of RAM connected via ethernet.

…* no raspberry emoji 😔

🐳 Project setup

The project’s setup is very simple.

I use Docker Compose to run three containers:
- The app — contains the Python code to run the speed tests
- Postgres DB — stores the results
- Superset — visualises the results

Here’s the docker-compose file. I use dummy credentials since it will all be running inside my local network.

💻 The app container

The app container leverages the speedtest-cli library, which allows me to easily run a speed test programatically using only 5 lines of code.

Then I used SQLAlchemy to build a model to easily save the results to the Postgres Database.

Finally, for the scheduling I set up the Docker container to run a cron job which executes the main script every 10 minutes. This main script runs the speed test and logs the results to the database.

📈 The Superset container

Apache Superset is a great open source platform for visualising results, and works very much in the same way as Tableau and PowerBI do, through a drag-and-drop interface.

The project contains a prebuilt dashboard with charts that are relevant for this project’s objective, but you can easily add new ones if you want to explore the data further.

I had to build my own Docker image to run Superset because the image available on DockerHub is for amd64 architecture while the Raspberry Pi has an arm architecture. I’ve tested both on my Linux amd64 and my Raspberry Pi 4 and the project’s image works fine on both platforms 👍

The dashboard contains the following plots:

Average upload and download speeds per hour

Upload and download speeds over the last week

This plot shows the average measurements by hour of the day. It’s interesting to notice that there is a daily pattern on the upload speed. There seems to ‘dip’ everyday at around midday. The download speed is also quite erratic, but consistently around the 100MB mark.

Average speed by day of the week

Average speed by day of the week

The speed by day of the week doesn’t have that much variation. Mondays and Saturdays seem to be the slower days, but they are all consistently around the 100MB mark. Weekends seem to have slightly higher upload speeds.

Average speed by hour of the day

Average speed by hour of the day

As we discovered in the first plot and is then confirmed on the above bar chart, the upload speed is, on average, slower between 10 am and 5 pm.

This is probably due to a high demand from the video calls during the weekdays. I quickly drew up a boxplot to compare upload speeds between 9am and 5 pm by day of the week, and this seems to be the case.

Distribution of upload speed by day of week, between 9am and 5pm

🎯 The Verdict

In conclusion, it seems my internet provider has, on average, provided the promised speeds!

This is helpful, as now I know it’s a problem on my side. Hopefully this tool will help you identify where your internet problems lie.

If your internet provider is to blame, now you have the evidence to prove it!

All the code and instructions on how to run the tool are available here.

👏👏 Try it yourself — and let me know how you get on in the comments!

Applied Data Science Partners is a London based consultancy that implements end-to-end data science solutions for businesses, delivering measurable value. If you’re looking to do more with your data, please get in touch via our website. Follow us on LinkedIn for more AI and data science stories!

--

--