P
P
pavelkunyavskiy2018-02-13 13:29:00
MongoDB
pavelkunyavskiy, 2018-02-13 13:29:00

How to save real-time page views?

Here I want to make real-time statistics of page views. Those. a unique client makes a request to the database - and I increase the number of views and save it.
At the same time, I plan to do it this way - when requesting a specific API route, the Node searches the database for the necessary data (content data for a specific page), after that it +1 to the value viewsin the same object and returns the already updated data to the client with its view.
The question arose - what if there are high-load situations, when there will be many simultaneous visitors? Well, relatively speaking, in one second, 10 people will make a request to the database. Then questions arise.
1. Is query execution blocked in the database? I am using NodeJS and Mongoose. Or will all these 10 people become "in line"?
2. What value will the visitor return if they visit at the same time?
3. What is the right way to do this? I feel my solution is not correct for such a task.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question