java - How to track users viewing habit -


i need keep counter couple of pages each user visits.

lets need keep counter page 1 , 2. usera visits page 1 10 times therefore counter should 10, , userb visits page 1 5 times , page 2 7 times user's counter page 1 should 5 , page 2 should 7.

countertable ( shows number of times each page has been visited each user)   username page counter          1    10  b         1    5  b         2    7 

to achieve this, have table in db keep usernames, page numbers , counters, every time user visits page associated counter in db incremented.

my question that, if increment required counter, every time want retrieve pages (1 or 2) user needs wait application required record updated before visiting page.

to avoid this, should use jms send asynchronous requests increment counters in database? option, use ajax maybe send async request server.

is there more efficient method it? if not 1 more efficient?

making assumption counter audit purposes instead of display purposes, option may write access log locally. recommend standard format such ncsa common log format defines fields url, method , user among others, of course there many other options available well. may have such logging built javaee container or libraries, , have turn on.

you use tool splunk or logstash, or others pick , aggregate data outside of request flow, , collect of servers. keeping raw access data around, can further analysis, beyond how many times did particular user view particular page, answering questions such times of days / days of week particular users active, have servers seem getting more requests others? particular pages popular around particular times? , many more.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -