Hello!

I am thinking about how to organize data storage in one potentially highload project, I decided to consult. The task is this: there is a list of "candidates" (~ 20 pieces), there are people who give a ball to everyone (at a time). It is necessary to display the current rating of candidates, i.e. After each vote you need to recount ~ 20 numbers. What are the options:

  1. Just take PostgreSQL and save user voices in a table. Rating calculation occurs in the application code, and is cached.
  2. Again, use a relational database, but in addition to saving user votes immediately store a recalculated rating in a certain table. To recalculate the rating, use the message queue, or do it by crown.
  3. The first way, but use NoSQL solution.
  4. The second way, but use NoSQL solution.

I tend to NoSQL database and caching rating calculation, without denormalization. What would you do?

Thank!

  • And why do the recalculation in the code, and not in the PgSQL? Do you have very complicated maths there? It has built-in aggregate functions that will give odds to many programs. Not to mention the analytical queries. - Dex
  • You can recalculate in PgSQL, but I think this is not the point if you cache the result. - Taras
  • With such a small amount of data as easy (taking into account the reliability) and do. - avp
  • Hayload is how many in numbers? - Andrew Frolov

1 answer 1

Dumb is not clear how your rating is calculated. Perhaps - in relation to other parameters: it means that a lot of data is taken from the database and for rendering it is run in the script? If so, then I think it is better to do all the calculations in the database itself. Now about the base. The guys correctly said that you have few users and in the case of a small number of voters you can use only the nosql solution (for example, redis can save data to disk). Recalculation in this case will be possible only in the script.

PS: Give the algorithm (theory only) how the rating will be calculated and stored. Maybe smart guys will tell you how to remake the datalogical model or you will get a more specific answer.