Question

In social networks there two basic ways to deal with profile pages presentation:

1) Every time that a page is requested, a query is sent to the database and the profile page is built.

2) Every time that a profile is updated, a new html page is automatically built for future reference and requests.

There are advantages in both approaches. While in (1) it is not necessary to keep the pages, in (2) is not necessary to access the database every time that a profile page is requested.

Is there a kind of common sense to deal with profile pages? Are there other ways to deal with this problem? Are there issues that I am not considering here?

Any help will be greatly appreciated.

Was it helpful?

Solution

Option 2 will not scale well at all. Even at 0.1% of Facebook's traffic, you'd be generating HTML pages often enough to completely choke your storage's throughput.

Option 1 can be scaled infinitely (well, not infinitely, but you get the point) easily by sharding your DB, adding memcache etc.

Further, what happens when you decide to change the layout of the profile page? You'd have to regenerate the profile page for every user, which would be very expensive.

Option 1 allows you to decouple layout and presentation, from the data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top