AWS for M&E Blog
Behind the scenes: AWS real-time architecture for Bundesliga Match Facts
This blog was co-authored by Alexander Smirnoff, Senior Cloud Applications Developer, and Kirill Serykh, Data Scientist, from Sportec Solutions AG.
Bundesliga, Germany’s premier football league, uses Amazon Web Services (AWS) to deliver near real-time statistics and in-depth in-game insights called Bundesliga Match Facts (BMF). These statistics are used to create personalized content for 500 million global fans and provide advanced insights into players, teams, and the league. These statistics are also supplied to national and international broadcasts to better engage fans.
As of now there are 15 BMFs that run inside the Bundesliga Match Facts platform (also referred to as system). This blog post provides a look at the underlying infrastructure that enables near real-time statistics delivery. The post explains how this event-driven, serverless architecture is designed and built, using AWS technology, to be a highly scalable and cost-efficient solution for Sportec Solutions AG, a joint venture between Deltatre and DFL Group.
The BMF platform’s main functionality is its near real-time data analytics, based on machine learning and advanced heuristics using live streaming data. During a match, the system processes over 3.6 million events with positions of players and the ball, human-curated data points about the game (passes, goals, offsides, fouls, etc.), and updates about teams and players. Each of these events needs to be collected, parsed, and analyzed within seconds while the event is still relevant for the audience, a challenge solved by building the solution described in this post.
The high-level architecture depicts the handling of the huge number of real-time events coming into the BMFs. The process starts with an AWS Lambda function executed by an Amazon EventBridge Scheduler that checks if a game is running, and spins up required Amazon Elastic Container Service (ECS) tasks for that match (if not already running). One of these containers uses a web socket connection to process the live data and forwards it to the Amazon Managed Streaming for Apache Kafka (MSK) cluster, which is then consumed by the BMFs. Another lambda function is attached to an Amazon API Gateway, which gets HTTPS pushes for metadata during the game. Data from Amazon MSK is collected per statistic and game by stateful containers running on ECS with AWS Fargate (BMFs), which then combines the data from the different sources.
As a next step, the containers use the combined data to perform data analytics. Amazon S3 buckets are introduced to store all inputs and produce outputs for data archival, on-demand game simulation, ad-hoc analysis, and troubleshooting purposes. The primary communication channel of the event-based system is an Amazon MSK, which connects all parts of the system. Each of the system components subscribes to Kafka topics and reacts to relevant events and writes the output back to MSK.
Diving deeper into the solution, a major challenge is streaming substantial numbers of events as well as ingesting these events into multiple BMFs, all while ensuring asynchronous processing and delivering statistics in near real-time. To address this challenge, the system is designed following the event-driven architecture (EDA) pattern.
The core of the system is an Amazon MSK cluster responsible for distributing events among all system components. As a simplified route, an ingress service receives near real-time data from the upstream data source, and pushes the events into the MSK cluster. Each BMF consumes events and processes them with machine learning models hosted on Amazon SageMaker and pushes the result back into the MSK. Two lambda functions are then triggered. One sends the result back to the data source so the calculated statistics are delivered to fans via broadcasting and mobile application, and the other lambda function writes the result to Amazon RDS Aurora for use in business intelligence and quality control dashboards.
Utilizing an event-driven architecture in this context offers several compelling advantages. Most importantly, it provides the platform near real-time responsiveness to the events happening during the match, and shows the result to the audience while still relevant. Furthermore, EDA serves to decouple various system components; currently there are 15 BMFs running for each game, with events acting as a communication mechanism between different components.
While EDA brings numerous benefits to the system and offers many out-of-the-box features, it also introduces certain challenges. For starters, adopting EDA adds complexity to the system, as managing event producers, event consumers, and event routing still requires additional development efforts. This is addressed by abstracting base Kafka consumers and producers in a shared module between different components, defining all the Kafka payload types in a central module, and introducing Pydantic (a widely used data validation library in Python) for payload structure validation.
EDA also poses challenges for debugging and monitoring the system, as it is difficult to track the event flows within it, diagnose issues, and monitor the platform’s behavior. To help with flow tracking and debugging, all logs are forwarded into DataDog (an observability service for cloud-scale applications) and DataDog tracking is used to gain a clearer insight into the event flows between each system component.
The system leverages AWS Serverless technology with the use of various Amazon Lambda functions, API Gateway, Amazon DynamoDB tables, Amazon SageMaker endpoints, and Amazon Aurora Serverless Database, which offers a number of advantages, particularly in terms of scalability, cost efficiency, and low-maintenance. With this serverless architecture, the system effortlessly adapts to fluctuating workloads, ensuring it scales automatically to accommodate changing demands during match days. This scalability is crucial in providing real-time updates and maintaining a highly responsive system.
In terms of cost efficiency, a customer pays only for the resources they actually use. During less busy times such as weekdays when there are no ongoing matches, the system consumes fewer resources. For example, by leveraging AWS Fargate, a significant 99.9% reduction of costs is achieved compared to traditional fixed server setups.
Using serverless services also helps in simplifying the building and maintenance of the system by focusing on the development of business features rather than the underlying infrastructure, thus leading to faster development cycles and improved productivity. Other benefits include enhanced security and seamless integration with other AWS services.
In conclusion, the Bundesliga Match Facts platform powered by AWS has transformed how fans around the world experience football stats by receiving lightning-fast, personalized game insights in near real-time. Through the use of event-driven architecture and AWS serverless technology, a robust and resilient platform is created, which ensures near real-time responsiveness, smooth operation, scalability, cost-efficiency, minimal maintenance, and effective management of streaming data in a distributed environment. This achievement sets unprecedented benchmarks for a dynamic sports experience.