I’ve been a member of a lifelong keeper hockey pool for quite a few years now. It started as an excuse to keep in touch with friends from University but quickly evolved into a very serious league where stats are king and the ridicule is unforgiving and never stops.
When we first started, we kept all the stats in an Excel spreadsheet. It worked fine, but it involved a ton of manual labour and took forever to publish. Since we’re all more competitive than we like to admit, long breaks in standings meant almost everyone was keeping their version of the stats just to get their fix.
At some point we decided, probably for sanity’s sake, that Excel wasn’t cutting it anymore and that it was time to use a Hockey Pool website. We’ve used a few and, for the most part, they were just fine. In the beginning, the pool was quite simple, one draft, no changes, straight points. As time went on and we wanted something more, we started allowing drops, and taxi squads.
Most of the websites we were using were free or very close to free, and as the pool became more advanced, they didn’t cut it anymore, so I decided that it was time to build something custom.
I’ve been involved in Amazon Web Services (AWS) for quite some time now - almost since the beginning, and I love it. I have yet to come across a situation where I’m not able to piece together AWS services to build an application.
The Hockey Pool was no different. I decided that building something from scratch was the way to go. Not only would it be a great learning experience, but I was pretty sure I could build something pretty cool.
So I pieced together an application using Simple Queueing Services (SQS), Elastic Compute Cloud (EC2), Elastic Load Balancing (ELB), Simple Storage Service (S3), and Relational Database Service (RDS).
I decided against using Auto-scaling because with only seven members it’s not likely to see much traffic….let’s hope I made the right decision.
Members of the hockey pool visit an HTTP site where they can see current standings (up to last night), see leaders in a bunch of categories, and view information about the players on their rosters (pro and taxi).
The rest of this article talks about how I built the AWS solution for our hockey pool - Enjoy.
First, what would a hockey pool be without stats. For the pool site, I use a 3rd party source for all our stats and the applications start there.
On a daily basis, a Python (Boto) script running on an EC2 instance downloads all the stats we need (three unique files) and stores them in S3 for later processing. Once it successfully stores the files in S3, it creates a job in one of three SQS queues that are dealt with later.
Here’s a representation of “Getting The Data."
Stage two is all about parsing data. Each morning we download stats for all NHL players from the day before, plus a running total for the season.
The biggest parsing job is the parsing of last night’s results. A Python script wakes up and checks its SQS queue. If there is work to be done it downloads the correct XML stat file from the S3 bucket and gets down to work. The script gathers information about each active player from the night before and stores all that data in a Multi-AZ RDS instance.
Once that job is complete, another Python script watches for any ‘team’ work that needs to be done. It checks its queue and then calculates each team’s total points, points from forwards, defence and goaltenders. All this information is also stored in the MySQL RDS instance.
The majority of the hard work is now finished. Now it comes down to presenting that data in a simple way so that the members of the league can see how they are doing compared to the other owners. They also see details about the players on their rosters and their taxi squad.
This is pretty simple really. Under the covers, it’s a custom built PHP Framework (that I use everywhere) with Bootstrap helping to make it all look pretty.
There are quite a few things that I would like to add to the site - namely using Lambda. I work on the pool site on my spare time and use it as a learning platform, so changes happen when I find the time.
Like what you read? Why not subscribe to the weekly Orbit newsletter and get content before everyone else?