You are browsing a read-only backup copy of Wikitech. The primary site can be found at wikitech.wikimedia.org

Difference between revisions of "Event Platform"

From Wikitech-static
Jump to navigation Jump to search
imported>Ottomata
imported>Ottomata
Line 5: Line 5:
  
 
Instead of updating a database when a state change happens, we can choose to model the state change as what is is: an 'event'.  An event is something happening at a specific time, e.g. 'page id 123 was renamed from title_A to title_B by user X at 2020-06-25T12:34:00Z'.  If we keep the history of all events, we can always use them recreate the current state as well as the state at any point in the past.  An event based data model decouples the occurrence of an event from any downstream state changes.  Multiple consumers can be notified of the events occurrence, which enables engineers to build new systems based on the events without interfering with the producers or other consumers of those events.
 
Instead of updating a database when a state change happens, we can choose to model the state change as what is is: an 'event'.  An event is something happening at a specific time, e.g. 'page id 123 was renamed from title_A to title_B by user X at 2020-06-25T12:34:00Z'.  If we keep the history of all events, we can always use them recreate the current state as well as the state at any point in the past.  An event based data model decouples the occurrence of an event from any downstream state changes.  Multiple consumers can be notified of the events occurrence, which enables engineers to build new systems based on the events without interfering with the producers or other consumers of those events.
 +
 +
== Background reading ==
 +
* [https://assets.confluent.io/m/7a91acf41502a75e/original/20180328-EB-Confluent_Designing_Event_Driven_Systems.pdf Confluent - Designing Event Driven Systems]
 +
* [https://www.confluent.io/blog/data-dichotomy-rethinking-the-way-we-treat-data-and-services/ Confluent - The Data Dichotomy: Rethinking the Way We Treat Data and Services]
 +
* [https://www.confluent.io/blog/stream-data-platform-1/ Confluent - Stream data platform 1]
 +
* [https://www.confluent.io/blog/messaging-single-source-truth/ Confluent - Messaging as the Single Source of Truth]
 +
* [https://www.confluent.io/blog/build-services-backbone-events/ Confluent - Build Services on a Backbone of Events]
 +
* [https://medium.com/@hugo.oliveira.rocha/what-they-dont-tell-you-about-event-sourcing-6afc23c69e9a What they dont tell you about event sourcing]
  
 
== Event Platform generic concepts ==
 
== Event Platform generic concepts ==

Revision as of 18:15, 8 July 2020

The Wikimedia Event Platform exists to enable software and systems engineers to build loosely coupled software systems with event driven architectures. Systems built this way can be easily distributed and decoupled, allowing for inherent horizontal scalability and versatility with respect to yet-unknown use cases.

Philosophy and data model

In typical web stacks, when data changes occur, those changes are reflected as an update to a state store. For example, if a user renames a wikipedia page title, that page's record in a database table would have its page title field updated with the new page title value. Modeling data in this way works if all you care about is the current state. But by keeping only the latest state, we discard a huge piece of useful information: the history of changes.

Instead of updating a database when a state change happens, we can choose to model the state change as what is is: an 'event'. An event is something happening at a specific time, e.g. 'page id 123 was renamed from title_A to title_B by user X at 2020-06-25T12:34:00Z'. If we keep the history of all events, we can always use them recreate the current state as well as the state at any point in the past. An event based data model decouples the occurrence of an event from any downstream state changes. Multiple consumers can be notified of the events occurrence, which enables engineers to build new systems based on the events without interfering with the producers or other consumers of those events.

Background reading

Event Platform generic concepts

event A strongly typed and schema-ed piece of data, usually representing something happening at a definite time. E.g. 'revision create','user button click', 'page view', etc.
event schema (AKA 'schema') A datatype of an event. The event schema describes the data model of any given event and is used for validation upon receipt of events, as well as for data storage integration (an event schema can be mapped to an RDBS schema, etc.). An event schema is just like a programming data type.
event stream (AKA 'stream') A contiguous (often unending) collection of events (loosely) ordered by time.
event bus A publish & subscribe (PubSub) message queue where events are initially produced to and consumed from. WMF uses Apache Kafka. (NOTE: here 'event bus' is meant to be a generic term and is not referencing the MW EventBus extension).
event producer Producers create events and produce them to a specific event streams in the event bus.
event consumer Consumers consume events from specific event streams in the event bus.
event intake service An HTTP service that accepts events, validates them against their schema, and produces them to a specific event stream in the event bus. WMF uses EventGate.
Event stream processing Refers to any software that consumes, transforms, and produces event streams. This includes simple event processing, as well as complex event processing. This is usually done using a distributed framework of some kind, e.g. Apache Flink, Apache Spark, or Kafka Streams, but also includes simpler home grown technologies like Change-propogation.

Event Platform documentation pages

Platform Architecture Diagram

Modern Event Platform Architecture Diagram.jpeg

Historical Overview

The first 'event platform' at WMF was EventLogging. This system originally used ZeroMQ to transport messages between its various 'services' but was later improved to use Kafka. It was built for WMF product teams to be able to instrument and measure WMF features and usage on websites and apps. It used a (hardcoded) on-wiki event 'schema repository' to validate incoming events.

In 2015, an effort was made to extend the analytics focus of EventLogging to production events. This effort was dubbed 'EventBus' and culminated in three new components: the Mediawiki EventBus extension, the mediawiki/event-schemas git repository, and eventlogging-service-eventbus. eventlogging-service-eventbus is the first HTTP POST (internal) endpoint. It validated and produced events against more tightly controlled production schemas, and produced them to Kafka. EventBus was used to build the Change Propagation service. We originally intended to merge the analytics vs. production uses of EventLogging.

In 2018, we started the Modern Event Platform program, which included EventBus's original analytics+production unification goal as well as other parts of WMF's event processing stack using open source (non-homegrown) components where possible. The EventLogging python codebase was too WMF and Mediawiki specific to easily accomplish the unification, so it was decided to build a new more generic and extensible JSONSchema event service, eventually entitled EventGate.

In 2019, EventGate, along with other Modern Event Platform components, replaced eventlogging-service-eventbus, and is intended to eventually replace as the 'analytics' deployment of EventLogging services (e.g. eventlogging-processor).