I am developing a page view counter to track the amount of views a page is having on our site and displaying it to the user. (I asked an intro question before: Page View Counter like on StackOverFlow).
Using the recommendations, I developed a httpHandler which will handle the request whenever this gets fired off:
<link rel='stylesheet' href='cn.axd?t=1&id=232' type='text/css' />
-
Just wondering if the end-user would need to wait for the request to be finish processing before they can view/interact with the page.
-
Would a better choice be implementing an asynchronous queue where information gets logged to an MS Queue and eventually logged in the database via (Exception Policy)
-
Would it be slower to check if a certain record exist (PageID) and increment a counter or insert the record into the database and aggregate later when needed. We would just need to run an aggregation at the end of the week to see the total amount of pageviews a particular page got over the week.
Thanks all.
interesting questions! Like a lot of other performance-tuning questions, there are some tradeoffs.
Possibly. It may be a better idea to load this handler inside an IMG href=”, setting the sizes to 0 so it is invisible to the user.
With heavy load this would be preferable, that way your handler can return immediately after queuing the operation. For most loads, however, it is probably just as quick to run a simple T-SQL query to increment a counter.
Adding +1 to the value directly within your T-SQL query would probably be the best, ‘count = count + 1’ etc. That would be quick to run and would result in subsequent retrieval of your data without aggregation.
Hope this helps!
Adam