I have been messing around with social network design. One of the things that I have taken a long time getting right is linked list insertion. For any feed based social network the feed query is the most important query in the system. This query will be executed the most and needs to be performant. The method I thought of pursuing was to have the feed in a linked list hanging off every user so in order to fetch the latest stories for the user you could do a query like
MATCH (user)-[:FEED*]->(story) to return the feed for a user. However in order to do linked list insertion you need to take a lock. The lock worries me for the following reason. When (User A) posts a story you will need to take a lock on every follower of (User A) in order to insert this story (or a link to it) in the followers feed. As you have to take a lock on every follower there is a high possibility that someone else that they are following may be posting at the same time leading to possible deadlock. This possibility of deadlock increases when the number of followers increases. There are multiple ways to implement news feeds, there is another here - http://docs.neo4j.org/chunked/snapshot/cypher-cookbook-newsfeed.html you will notice that this query would span multiple relationship types and have to do an order-by as well. The data model for it is a lot cleaner though. I am wondering if there are people who have implemented news feed applications who would be willing to share some of the ways they have implemented this feature and the associated data structure that has been used. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
