Hi Atul,
Thanks for the question! Here is how I would do it:
- I would pick a NoSQL DB like MongoDB to store details such as
views , upvotes etc.
- Every time someone upvotes a post or views an article you don't want to hit the DB and eat up the resources. So, I suggest you start with Redis. Each time an article is upvoted or viewed you can store the count in a Redis key (keep incrementing it). Every 5 mins you can flush the count to your database through a single update command. This task should be performed by a separate service and not your main app.
- With this approach your users may see stale upvotes, views etc but it doesn't really matter.
P.S. I chose Mongo as I more comfortable with it. But feel free to go ahead and use an SQL DB like MySQL if you like. I don't think it will have major impact as you are anyway caching the upvotes/views and issuing a single update in specific intervals.
Hope this helps. Feel free to ask more questions.