How is 10 million questions generated when using stackoverflow?

Stackoverflow celebrates 10 million questions. Congratulations!

Providing us with this link: https://stackoverflow.com/10m

3 counters are displayed, and the number of each counter increases quickly, not statically.

However, I do not see any AJAX requests to display the last result of each counter.

I also have a counter on our forum, but to get the number of recent posts, I make an AJAX request every 3 seconds, running the SELECT MAX(id) AS total_posts FROM forumposts to display.

I know this is not the best solution that we have, and it will be wrong if the message is deleted. Using the SELECT COUNT(id) command is too slow because we also have over 10 million messages.

So how does Stackoverflow show an increase in its counters without any queries? This seems to be the best solution for me, and I would like to use it for our forum, and then.

+5
source share
1 answer

It uses websockets. You can see it on the network tab. wss://qa.sockets.stackexchange.com/ From the request, it looks like it receives a total quantity every day. enter image description here

SQL counter is slow The poor way to improve performance is to track statistics yourself, creating a table that tracks the number of rows. You will be saddled to update this table every time you delete or add new entries. Before you do this, do some research on indexes and the following questions.

+7
source

All Articles