Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there standard approaches to persisting data for every hit that a web app receives? This would be for analytics purposes (as a better alternative to log mining down the road).

Seems like Redis would be a must. Is it advisable to also use a different DB server for that table, or would Redis be enough to mitigate the impact on the main DB?

Also, how common is this practice? Seems like a no brainer for businesses who want to better understand their users, but I haven't read much about it.

share|improve this question
why do you think redis is a must? – BrokenGlass Nov 21 '12 at 5:00
@Broken Seems like you'd want to avoid writing to the db as much as possible, which Redis would accomplish by only writing periodically as opposed to writing on every user action. In practice I'm not sure what difference it would make, but it seems like a good use case for Redis. – bevanb Nov 21 '12 at 5:07
These analytics can almost always be processed effectively from standard server logs – rvalue Nov 21 '12 at 5:13
@rvalue Log mining seems suboptimal. Lots of overhead in making sense of data that could have easily been stored in usable form beforehand (and real time rather than some long background job). – bevanb Nov 21 '12 at 5:26
I don't think Redis is a must. We custom roll our own analytics stuff. – Deco Nov 21 '12 at 5:38

I think it's far more common to just use conventional logging to a textfile. Most webservers can log all the requests. You can analyze those external to any application that handles the requests.

Just keep it cheap and simple. You could still use Redis when making a reporting solution by importing the log files.

share|improve this answer
+1: Logging isn't just for errors. – Steve Evers Dec 12 '12 at 20:29

Use a service layer

tl;dr - log errors on the server-side, log analytics by sending an ajax request to a data tracking service from the client-side.

Just create a thin service layer to track data and fire an AJAX request to it from your site.

The request will contain all the data you want, just create a database to log the specific attributes you want.

Isn't that the basic concept behind most statistic tracking services? A request contains a lot of information about the user.

It won't provide error tracking but that's what the server logs are supposed to be for in the first place.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.