E
E
Evgeny Seleznev2011-05-04 16:22:47
Feeds
Evgeny Seleznev, 2011-05-04 16:22:47

Newsfeed implementation?

Gentlemen, maybe someone faced the task of implementing a news feed? Interested in your thoughts/solutions.
It should look something like this:
In our feed, we see our events + events of those who are subscribed
. For subscribers, we see only their events.
I see two options:
1). A separate stream for each user (a certain structure in the database / channel in the comet / etc.)
In this case, it is inconvenient to show your feed - you will have to drag the feeds of everyone you are subscribed to and sort them.
2). When adding an event, shove it into your feed + into the feeds of those who subscribe to us.
Minus - it turns out a rather large overhead (copies of the same event are stored in different feeds)
Advise something, thanks in advance.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
Innsbrook, 2011-05-04
@Insbrook

If you do not have a lot of users and there are almost no feed settings, you can store all the news without duplication and make a selection, as advised above.
However, what happens if there is not only a table of subscribers, but also a table with information about the privacy of news (to which of the subscribers what to show), there is a table with information about people whose news you do not want to see in your feed (however, you do not delete from friends , For example). It turns out that with each such feature, the request to display the news feed will be overgrown with JOINs and nested queries, which will have a very negative impact on performance. In this case, it is better to sacrifice server memory and store the news feed for each user separately. Then the output of the tape can be a simple SELECT on the index.
I can advisean article about the update feed . You may be using a different DBMS, but the ideas and thoughts may be helpful.

V
Vlad Frolov, 2011-05-04
@frol

I see it like this:
1 table with all the news (no duplication), 1 m2m table for users and news.
To display our news, we make a selection according to the second table; in order to display the events of some individual person, we select by the owner of the news.

A
Alexander, 2011-05-04
@akalend

all news feeds are implemented through queue servers
; I advise rabbitMQ AMQP protocol
on Habré you will find a bunch of articles.

E
ertaquo, 2011-05-04
@ertaquo

IMHO, the first option is the easiest. Let the SQL server deal with sampling and sorting, it is intended for this in particular. It is implemented with a simple query like this:
SELECT * FROM news WHERE user_id = :current_user_id OR user_id IN (SELECT user_id FROM subscribes WHERE subscriber_id = :current_user_id) ORDER BY `date`

K
korotovsky, 2011-05-04
@korotovsky

I think you should take a look here: en.wikipedia.org/wiki/RabbitMQ

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question