redis - Should I use mysql or ssdb to store like/vote data? -


every user can vote videos, we're using mysql, have on 200 million lines in single table fields this:

id user_id     # voter video_id    # voted video author_id   # author of video state       # 1 normal , 0 cancelled, maybe others created_at 

the common query voters of specific video, maybe voters of videos author, or videos voted user needed, ordered time.

should shard table 100 shards (by video_id) or use ssdb instead?

if choose former, in order query author_id or user_id, data have stored several times.

if choose ssdb, think should use ordered set , store timestamp score sort, , have several keys each user or video in order query different fields , handle different states. , it's difficult change code , migrate data.

had same confusion. using both of them together:

  • redis caching hot data;
  • mysql data persistent;

no doubt more redis keys come more complexity, there must caching module reducing queries mysql.

and because use redis cache, data in can threw away @ time: can set new data structures in redis data mysql。

and don't want put data in redis: memory more expensive hard disk on iaas.

wish helps :)


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -