What is a practical deployment-write approach in redis?

I have a news site with many topics. There may be millions of users following topics. I support sorting for each user to download news related to the ones they follow. When the article is added or updated, I will write this article in the list of user users. In particular, the pseudo-code is as follows:

if a article is added/updated
  get all topics that the article belong (each article may belong to many topics)
    for each topic: get all topic followers
      update_user_news_list(userId, articleId)

This is java code with jedis:

static final int LIMIT_BATCH = 1000;
static void addToUserHomeFeed(int index, Jedis jd) {
        int range_limit = index + LIMIT_BATCH - 1;
        Set<String> list = jd.zrange("Follower:Topic:Id", index, range_limit); // get list of followers
        if (list.isEmpty())  return;
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
           // update user list
        }
        addToUserHomeFeed(range_limit + 1, jd);
}

The problem is that there are currently about 1 million users on my site, some popular topics followed by about 800,000 users, and sometimes the system generates buffer overflow errors. Am I doing something wrong or are there better approaches? I am using redis 2.4

+4
1

, Redis, , + :

ZADD lasttopics -[timestamp] Topic:1-Article:1 -[timestamp] Topic:2-Article:1 

1 , 1 . unix ( )

, , , , , "ZSCAN lasttopics 0" .., , .

, , , 1 , ( , only) , 100 ) Redis.

maintenace .

0

Source: https://habr.com/ru/post/1535130/


All Articles