design - Efficiently record and store page view counts in the database? -


Show sites like Stacks overflow count, save, and display visual counts for pages. How do you do it efficiently? For example, we take the number of views for stack overflow queries. I look at the following options.

Option 1 When the application receives a request for a question, the count in the question table increases. It is very disabled! The majority of questions are read-only, but you are attacking every single update.

Option 2 Keep any type of cache that calculates the new view of the map questionIds. When the app receives a request for a question, increasing the view number cached for the question id you are caching marginal increase in ideas. So far, so good. Now you need to count in the cash from time to time. This is the second part of the problem. You can use another thread or some sort of scheduling component. This is actually a different question and partly depends on your server platform (I am using Java). Or, instead of using a different thread, after the number stored in a certain number in the cache, you can make an update within the request thread that reached the threshold Some IQ points in the cache can be updated in the cache.

I like the idea of ​​a cash when a threshold is reached. I want to know what others have done and if there is a better way.

I agree that writing every page in the database is disabled. My approach is to cache the requests, then do them once in one hour. Every time I update the cache, I compare the current time for the last lighttime, and if more than an hour has passed then I write. This is an ASP.NET application, so I have a final commitment in the application's shutdown method. The latter is not guaranteed to run, though acceptable loss is considered.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -