简体   繁体   中英

Best design pattern for storing News Feed in ElasticSearch

We have an mobile app with 5 millions users and now we are trying to design news feed based on ES. The goal is to have an opportunity for creating posts, storing them and subscribing for another users. So we need to choose posts for everyone depending on his subscriptions.

After some researching and googling I found some popular ways that could be used in our use case.

  1. Creating index-per-user . I think it's not a good idea for us, cos it needs for inserting a new post for each of the indexes of subscribers. Also, what if we have 100 millions of users?

  2. Create one index for all posts . And then for each user we can create an alias with filter by user ids that he is subscribed to. But then we'll have to hip on many shards while creating news feed for user. So there is 3 way.

  3. Routing by userId . It's a similar to 2 way, but the difference is that we create an alias per user with routing by it's userId. The disadvantage is that for each post in our index there will be as many copies as how many people should take it.

There are another patterns, that I've read. But I still have no clear vision - what will the best practice in our use case.

Also, we have an alternative to ES - Cassandra. But the decision is still in process.

Maybe someone could say his expertise in this question and give an advice. Critique is welcome too.

Thank you in advance.

您可以使用观察者模式,您的新闻将发送给您的所有订阅者

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM