Reputation: 786
I am trying to store and process sports events in realtime and want to create an optimal system as this will process 100s of events per second. The system will store the events before a sports match and then process them in real-time or at end of a half/session/match.
In my system, every Event
is broken down into following components
WHO
whom is the event related to. A team, player, refree,
spectators, etc WHAT
what is the event (goal, pass, save, etc)WHEN
time details of the event HOWMUCH
how is the event value definedTYPE
defines when should it be checked - INDIVIDUAL
: realtime,
AGGREGATE
: end of WHEN
Here are some examples for soccer
1. No goals scored in 2nd Half
TEAM: *, WHAT: __GOAL, WHEN: __HALF_2, HOWMUCH: 0, TYPE: AGGREGATE
{
"who" : {"team":*},
"what" : "__GOAL",
"when" : "__HALF_2"
"howMuch" : {"value":0, "type" :"exact"},
"type" : "AGGREGATE"
}
2. Either keeper to complete 3 or more punches
PLAYER: (p1 v p2), WHAT: __PUNCH, WHEN: __MATCH, HOWMUCH: 3+, TYPE: INDIVIDUAL
{
"who" : {"player":{"or":["p1","p2"]}},
"what" : "__PUNCH",
"when" : "__MATCH"
"howMuch" : {"value":2, "type":"more"},
"type" : "AGGREGATE"
}
3. Coutinho to score a goal before 65th min
PLAYER: p3, WHAT: __GOAL, WHEN: <65, TYPE: INDIVIDUAL
{
"who" : {"player":"p3"},
"what" : "__GOAL",
"when" : {"value" : 65, "type" : "before"}
"type" : "INDIVIDUAL"
}
4. Henderson to play highest number of passes
PLAYER : p4, WHAT: __PASS, WHEN: __MATCH, HOWMUCH: __MAX, TYPE: AGGREGATE
{
"who" : {"player":"p4"},
"what" : "__PASS",
"when" : "__MATCH",
"howMuch": "__MAX" // this is a key word which will be handled accordingly on the application
"type" : "AGGREGATE"
}
5. Liverpool to have more possession than everton
TEAM: (t1 > t2), WHAT: __POSSESSION, WHEN: __MATCH, TYPE: AGGREGATE
{
"who" : {"team":{"compare":["t1","t2"],"winner":"t2"}},
"what" : "__POSSESSION",
"when" : "__MATCH"
"type" : "AGGREGATE"
}
All AGGREGATE
events will be checked when the state of the match changes. e.g. IInd half ---> MATCH_END
All INDIVIDUAL
events will be checked for in real-time (as soon as a new event is received). This works on web hook.
E.g. A goal is scored in the 58th minute.
Event received by system - {"type":"goal","player":"_henderson_", "minute":58}
The system would now run a "find" where ("type" == "INDIVIDUAL" && "what" == "__GOAL")
and compare all the events found.
Later on, I would like to provide an admin functionality for writing sentences which can be parsed into this structure. What I want to know is if I am working in the right direction or do I need to start thinking in a different way.
Upvotes: 9
Views: 222
Reputation: 767
Your choices are probably between Spark and Dataflow. Here's a nice white paper comparing the two that actually uses a similar use case to yours (large scale mobile game user scoring in real time). Good luck, seems like a cool project (looks like an online bookmaking implementation?).
Upvotes: 2