开发者

Newsfeed Architecture

开发者 https://www.devze.com 2023-03-11 07:46 出处:网络
For a project I\'m working on I need to implement a newsfeed similar to Facebooks\' with the difference being that it would be refreshed at a rate similar to that of a chat room and that the feed woul

For a project I'm working on I need to implement a newsfeed similar to Facebooks' with the difference being that it would be refreshed at a rate similar to that of a chat room and that the feed would be contributed to by users (only status updates). I was planning on using Thrift, with php on the client and C++ on the server.

Because the refresh rate needs to be so high, on the server, I was thinking of 开发者_运维百科keeping the last ~20 entries to the feeds in a linked list (or similar structure) in memory for quick access (since anyone refreshing only needs the latest entries) while sending any old entries to a mysql database for storage.

Does this seems like a proper architecture for this implementation? If so, what would be a good way to send the old entries to the database?


Send all items directly to the DB, but keep a list with the latest 100 or so.

If you are using the repository pattern, keep the list inside your repository class and add a method called GetLatest. The rest of your application shouldn't care if they are cached or not.

If you are using nhibernate, you can turn on caching and have nhibernate take care of it for you.


Considering using memcached in front of your database. That's what it's designed for.

But before you even do that, just implement the thing with no caching. See how it goes. Maybe it will work fine with a fairly boring implementation


Sorry for the simplistic answer but I would send entries to the database as they arrived at the server, not as the "aged". No point in waiting. Then you can use your DB as storage repository and query it when a new client arrives for the last 20 entries.

0

精彩评论

暂无评论...
验证码 换一张
取 消