educative.io

Redis Hash/60 Entries calculation of storage

How much memory we would need to store all the user data for sliding window with counters? Let’s assume ‘UserID’ takes 8 bytes. Each epoch time will need 4 bytes, and the Counter would need 2 bytes. Let’s suppose we need a rate limiting of 500 requests per hour. Assume 20 bytes overhead for hash-table and 20 bytes for Redis hash. Since we’ll keep a count for each minute, at max, we would need 60 entries for each user. We would need a total of 1.6KB to store one user’s data.

I have two questions from the about paragraph…

  1. 20 bytes for Redis hash(i dont understand why we are calculating the Redis hash here)?
  2. Since we’ll keep a count for each minute, at max, we would need 60 entries for each user.
    why we need 60 entries, i didn’t get why number 60?