I’m building a network of services, and all the services are completely different from one another, and now I’m creating a dashboard to make the experience easier to work with, creating an automatic list of the services the user uses most.
But if I want to find out which products the users use the most, how would I do that without causing heavy overload on the server? By that, I mean whenever a user goes to a page on that service, ie http://foo.com/bar/nyancattastic2.php I would find the keyword (app name) being ‘bar’, and then add a hit, by updating the row where the username is matched to ‘bar’ in my database with hits=hits+1
Although, putting that on every page would really destroy my server with an update query on every page.
Any ideas? Alternatively, I could ask the user what their favorite apps are, but that’s more a UX question.
Any help greatly appreciated!
Cheers,
Karan
Edit* The levels of traffic I expect are around 3-10 Queries/Second without this suggested change!
Thanks for all the answers!
Well it depends on your load, if there are several queries per seconds, it can become a problem because when you do an update field = field + 1, you do an implicit lock on the field.
If you do have that level of traffic, you can consider instead to write a line to a log file and post process it, or add a line to a mysql table, that will get periodically aggregated. Another idea is parse the webserver logs.
I personally got bitten by this update field + 1, when I tried to use it on a heavy traffic national soccer website, so yes, it can become a problem, but only at high levels of traffic.
Also check out the idea of Michael, to randomly sample users in case the load is really too high. With 3-5 queries per second you don’t have to worry, of course it depends on the server, but problems are likely to happen around hundred queries per second.