apps and services, similar to those in Facebook, Instagram and Twitter. Activity Streams and Feeds are typically the core experience of social networks, they are also used for notification feeds and audit logs. What is an activity stream?
• A community of ~1m users sharing content on engineering related activities • Portal of a number of popular tools to help engineers complete their projects • Steady stream of visitors, spikes during newsletter send out and big events • Really interested in reporting on site usage and analytics A little about DesignSpark
the system, rather than just its current state. • When using Event Sourcing, we describe our system’s actions by associating them with Events • Events are a point in the application’s timeline and should be immutable • Use the history of events to derive the current state • Classic example: Bank Account • Store the transactions that give you your balance, not just update your balance
of all activity that occurred on the site • Wanted to consider our ES activity store as ephemeral • Wanted to be able to rebuild the activity store and consumer network easily • Wanted the handling of activity to be done asynchronously • Wanted deep insights into what activity users were performing on the site • I saw a cool talk from Netflix on how they used it for their downloads feature
from the stream of events • Given a stream of events, we can project them to any structural representation • Could be SQL tables, NoSQL tables, Elastic Search index, whatevs • They work through listeners on the events which is used to build up these read models • The great thing about these read models is they can be considered ephemeral - you can always rebuild them through events
of which users are following who • user_statistics - to keep track of the stats for a user, e.g. no. of followers, no. of likes etc. • user_statistics_content - like the above but related to content, e.g. no. of articles created etc. • user_likes - to keep track of what content a user likes • user_watches - to keep track of what content a user is watching • activity_stream - yep, our ES activity stream is just another projection • consumer_network - same as above, just another projection
right • Aim to not need migrations, make schema complete & flexible • Rebuild !== Reconstitute • Aggregate ID from projection to retrieve events • i.e. to get all events for aggregate for reconstitution • Still learning
• Used for updates to the consumer network • Needs to guarantee ordering to ensure we don’t end up in situation where someone is following someone they have unfollowed or vice versa • Used for activity • Messages can arrive in any order
Christine { { Consumer Producers { • A consumer subscribes to 1 or more producers • A producer can be a user, item of content, a page; anything that can produce a notification • Need to keep track of these relationships
• Key concepts: Actor, Verb, Object and sometimes Target • Turns out we’re not the first to do this?! • Hello activitystrea.ms! { Verb { Alice added Why you should buy a Raspberry Pi? in Articles { Actor Object { Verb { Target
buy a Raspberry Pi? Who should be notified (see in their notification feed) from the above? • Alice should be notified in her activity log • Author of ‘Why you should buy a Raspberry Pi?’ should be notified that someone has commented on their article • Watchers of ‘Why you should buy a Raspberry Pi?’ should be notified Previous query would only notify followers of Alice, which wasn’t actually a requirement!
Description to JSON Array of Activity Stream Objects Specifies the public primary audience of an activity. cc JSON Array of Activity Stream Objects Specifies the public secondary audience of an activity. bto JSON Array of Activity Stream Objects Specifies the private primary audience of an activity. bcc JSON Array of Activity Stream Objects Specifies the private secondary audience of an activity. Activity Log Notification Feed where bto is me where cc is things inside my network OR where I am in to Put simply for our use case:
to be translatable, we do this on the front end using our standard translator • Need to know when a notification is unread • Dealt with by storing the time the user last viewed their notification feed • Comparing this with notifications since that date to get the number unread • Highlighting any after that date • Dealing with inflection, e.g. You followed Bob, Bob replied to your comment etc.