Http Performance - Many small requests or one big one

后端 未结 3 620
野趣味
野趣味 2020-12-28 14:37

Scenario:

  1. In my site I display books.
  2. The user can add every book to a \"Read Later\" list.

Behavior:

3条回答
  •  太阳男子
    2020-12-28 15:20

    Option 1 sounds good but has a big problem in terms of scalability.

    Option 2 mitigates this scalability problem and we can improve its design:

    Client side, via javascript, collect only displayed book ids and query once, via ajax, for an array of read-later info, only for those 30 books. This way you still serve the page fast and request a small set of additional info, once with a single http request.

    Server side you can further improve caching an in memory array of read-later ids for each user.

提交回复
热议问题