Giter Site home page Giter Site logo

newsfeed's Introduction

Samza newsfeed demo

This is an experimental sample project for Samza, demonstrating how to implement a Twitter-like real-time news feed. It uses an asymmetric follower model, where each user sees the messages posted by all users they are following.

Each time someone follows someone, that's a follow event. Each time someone posts a message, that's a message event. If you don't have real data, this project includes Samza jobs for generating a random social graph and random messages, respectively.

The fan-out job uses Samza's state management facilities to store the list of followers for each user. Every time that user posts a message, the fan-out job makes a copy of that message for each follower, and sends it to the follower on a separate deliveries stream. A downstream job then groups together all the messages that need to be delivered to the same user (called a home timeline, again implemented using Samza state).

How to run

Start YARN, Zookeeper and Kafka through Hello Samza's bin/grid start all script.

This job depends on Samza 0.8.0, which is not yet released. So you need to build it from source and put it in your local Maven repository, as follows:

git clone https://github.com/apache/incubator-samza samza
cd samza
./gradlew publishToMavenLocal

Then you can build and run the newsfeed jobs as follows:

  • mvn clean package && rm -rf deploy && mkdir -p deploy && tar xzf target/newsfeed-0.0.1-dist.tar.gz -C deploy
  • deploy/bin/run-job.sh --config-path=file://$PWD/deploy/config/newsfeed-fan-out.properties
  • deploy/bin/run-job.sh --config-path=file://$PWD/deploy/config/newsfeed-home-timeline.properties
  • deploy/bin/run-job.sh --config-path=file://$PWD/deploy/config/newsfeed-generate-follows.properties (if necessary; automatically terminates after creating a social graph of a certain size)
  • deploy/bin/run-job.sh --config-path=file://$PWD/deploy/config/newsfeed-generate-messages.properties (if necessary; keeps running and continually generates random messages)

You can use Hello Samza's kafka-console-consumer to inspect the output, e.g. the newsfeed-home-timeline-changelog topic.

Meta

This is experimental code, not fit for production use. It is released under the terms of the MIT license.

newsfeed's People

Contributors

ept avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.