Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate webpages directly from database or cache?

[I'm not asking about the architecture of SO, but it would be helpful to the question.]

On SO, when a user clicks on his/her name and clicks on "responses" they see other users responses to comment threads, questions, and answers in which they have participated. I've had the sneaking suspicion that I've missed certain responses out there, which made me wonder: if you had to build that thing, would you pull everything dynamically from the database every time a user requested it? Or would you modify it when there is new related activity in the application? Or would you build it in a nightly daemon process?

I imagine that the real answer is that it's dynamically constructed every time, but that the tables are denormalized in such a way so as to make the thing less time-consuming. How would you build it?

I'm asking about any platform, of course, not only on .Net.

like image 382
Dan Rosenstark Avatar asked Jan 23 '23 22:01

Dan Rosenstark


1 Answers

I would pull it dynamically from the database every time. I think this gives you the best result from a user experience and then I would apply the principal that premature optimization is evil. Later if there were performance issues I would look into caching.

I think doing it as a daemon/push process would actually result in more overall work being done. That is the updates would happen more frequently than the users are requesting the info.

like image 86
Brian Fisher Avatar answered Jan 29 '23 08:01

Brian Fisher