문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top