There is an application, a social network where people publish videos and can subscribe to each other.

So the question is, how do I need to create a subscription tape for a user (for which we have 200 subscriptions), how should I check the availability of new publications with those people I subscribe to? How to do it so that it would not put bd?

To make it clearer what I need, I’ll give the scheme of work that I have invented now (but as for me it’s too difficult for the server to execute. Do not pay attention to the errors of this scheme, I just brought it to understand what is needed):

The user enters the application and when opening the subscriptions window, a request is sent to the server. On the server in the database, the list of people that this user is subscribed to looks, then I take each person from this list and refer to his tablet in the database, I’m looking at whether there is a note about whether a new publication has appeared, and if I’m there, then I’m giving this publication to the user's subscription feed.

Zy. An example of what needs to be realized is the feed of subscriptions from Instagram.

  • Perhaps it is worth looking in the direction of storage such as Redis, for example? - ivan_susanin
  • It would be more convenient if you provided the base structure - Igor Lavrynenko

1 answer 1

It seems to me that first of all it is worth making a pagination, so that the server gives a certain amount of information to one request, and not all at once, for example, 10 records for each user. I, most likely, would not start from the “new” publication, but from the time of all publications. Get all followers of a user -> Get all entries for all followers of a user's followers in the last hour -> Give away all entries in chronological order. Or to give in parts on the pages page1 - the most recent and then pageN earlier records. Django able to paginate, I did it perfectly with a similar task. Perhaps there is a better solution, your question is about the architecture of the application, and this is not at all a simple thing.