Database design and optimization issues for a social application

The usual case. I have a simple application that will allow people to upload photos and follow other people. As a result, each user will have something like a “wall” or “activity feed” where he or she sees the latest photos downloaded from his friends (the people he or she follows).

Most features are easy to implement. However, when it comes to this story feed, things can easily turn into a mess due to pure performance considerations.

I came to the following dilemma: I can easily create an activity feed as a normalized part of the database, which will save me from recording cycles, but will significantly increase the difficulty in choosing these results for each user (for each photo uploaded for a certain period of time, select a specific the number whose users I follow / for each person I follow, select his photos)

An optimization option may be the introduction of a number of threshold restrictions, which, for example, would allow me to sort the people whom I adhere to by the date of their last upload, even exclude some, to save cycles and for each user, select only 5 (for example) last downloaded photos.

The second approach is to introduce a completely denormalized scheme for the activity feed, in which each line represents a notification to one of my followers. This means that every time I upload a photo, the database will put n rows in this "drop bucket", n means the number of people I follow, i.e. Many recording cycles. However, if I have such a table, I could easily apply some optimization methods, such as smart indexing, as well as trimming records older than a certain period of time (queue).

, , , , . , , friendfeed, , JSON .

, , , , . , - .

+5
5

, , , . ( ) , , , , , . , - , , .

+2

, , , . (), , . , , .

, - , . db , . ( , ).

, , , . ( ) .

, , ( ), . : , , , , . . , NoSQL, CouchDB, - , . , NoSQL - , .

, , : , , , . , , , , - . , , .

+14

,

  • , , CPU -
  • 24 ? .
  • SSD- .
  • , , , "" . , : id, user_id, event_name, date, event_parameters' - : 1, 8, CHANGED_PROFILE_PICTURE, 26-03-2011 12:34, <id of picture> , , . . , , , 3 , ( -) , . , SELECT .
  • INNODB history/feeds.

+7

, NOSql . , , . user- > wall user- > history, feed'ids ( redis). (n * read optimization) . . ( ) , push , user:: {userid}:: wall:: videos.

, memstores, 2 , , .

: , :

http://retwis.antirez.com/

http://twissandra.com/

+2

NoSQL , , . - , ( , ).

, , MySQL NoSQL - .

, , ( NoSQL), - (, , ). NoSQL ( SQL-, SQL), , .

Elad - , , . , , , .

+2

All Articles