There are a number of samples out there that highlight various cloud services in isolation. While they are good for learning a specific technology, the samples by necessity tend to be simple so that the details of working with the technology are lost in the complexity of the application code.
This series will walk through the process of leveraging an array of cloud services into a complete solution, a fantasy football (American) app. As we build out the application, we’ll talk about how the services integrate with the solution at large. We’ll also talk about the art of software engineering in general which goes beyond just writing code and managing cloud services. The goal is to code out loud and share lessons learned.
Fantasy Football is a popular game where players act as General Managers (GMs) of their own teams within a fantasy league for a season (or through a number of seasons). The players (for clarity we will call them GMs) participate in a fantasy draft where they select players from the NFL to form their own roster. Each week throughout the season, the GMs select a lineup from their roster to compete head to head with their opponents. Points are scored based on the performance of the real life players in their respective NFL games during the week. Points are assigned for different statistics (e.g.: passes completed, yards run, etc) and as the NFL player accumulates those stats, the GM with that player in their active lineup receives points accordingly. The GM with the most points wins the matchup. GMs can make trades of players in their roster, they can also pick up players from waivers (active players who aren’t on a roster). Just like the real NFL, fantasy leagues have playoffs and a championship game. The competition can be for money or bragging rights or both.
Fantasy Sport Center will allow people to sign up to participate in fantasy leagues. The user who creates the league will be a GM and commissioner of the league. They are responsible for the administration of the league. They can configure scoring, assign teams to conferences and divisions (which impacts ranking when determining playoff berths), invite GMs to join the league, and arbitrate disputed trades (e.g.: if a GM feels that a trade isn’t in good faith for the purpose of improving the rosters of both teams).
The system is responsible for keeping track of active players and their stats and updating fantasy points for the leagues according to their individual scoring rules. Users will be able to play the game from a web interface or from their mobile devices.
The primary goal of this project is to build a “reference implementation” of a “cloud native” Azure solution. As such, we will be using a cloud first approach. Where there is an Azure service that supports the needs of a given requirement, we will give it a strong preference. Where there are multiple options for a given requirement (and believe me there will be many), we will compare and contrast the pros and cons of each. We will use a handful of guiding principles in developing the system.
Why pay for compute power when you’re not using it? Take advantage of utility computing services. Troy Hunt, creator and maintainer of Have I Been Pwned, has several posts discussing how moving to a serverless model significantly decreased his costs for running the site. The difference being that Azure Functions uses a cost per execution model versus the standard PaaS or IaaS model of having an always running resource.
Costs aside, the serverless architecture provides benefits from a development and operations perspective. Since your operations are already broken into discrete units, it is easier to monitor, optimize, and debug them individually. As an added benefit, the platform handles scaling for you.
Cache All the Things
When you have durable data, rather than retrieving it from a database or storage on every request, processing the data, and returning the results to the caller, why not cache the results and save the load on your system?
Troy points out that 98% of the requests to his password match API are served by cloudflare, providing another cost savings on his Azure spend. Have I Been Pwned has a more static data refresh rate than a fantasy sports app, but if the API is shaped properly, the majority of requests should be cache hits. The only concern would be live game updates. For our scenario, we can use one minute delays for live games updates. Even with high volume requests during games, we should still see a high ratio of cache hits.
SOLID principles are guidelines for creating well architected systems. After following the principles for over a decade now, they are pretty much ingrained in my subconscious; but I will take the time to highlight how they apply to decisions made throughout the project.
We’re going to be “coding out loud” on this project, you can follow the github repo to watch our progress. We’ll be talking about major milestones and other details about the project here on the blog. I’m looking forward to exploring this space with you, stay tuned.