Home  >  Q&A  >  body text

javascript - I have a question about the data size for REST transmission at the front and back ends?

Just like Zhihu/quora and other websites, when reading user answers or articles, you can use read more or modal to read the entire article.

Now there is a similar business scenario. Each time the front end requests 15 articles from the back end, but my question is that some articles may have tens of thousands of words. In this case, whether the amount of data returned by restful-api is too large.

Since the questioner does not have a deep understanding of concepts such as network data transmission, will returning nearly 100,000 words of data at one time have a lot of impact on network delay? In other words, I only return the first few words of the article each time. When the user clicks read more, the front end will initiate a request to the back end.

淡淡烟草味淡淡烟草味2686 days ago760

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-06-12 09:21:43

    Ignoring network factors, this scenario needs to consider two points
    1. Server-side compression algorithm performance
    2. Server-side compression algorithm compression rate
    Generally, algorithm performance and compression rate are inversely proportional. In the most extreme case, the server does not perform compression, so the compression rate is 100% and the CPU overhead is 0%; on the contrary, the compression rate reaches 0.1% and the CPU overhead is 100%.
    Currently, servers will enable gzip compression, and the text compression rate can reach about 15%. Of course, it also depends on the text content. For example, the sorted text compression rate will be higher.
    Judging from the business scenario described by the subject, similar to preloading 15 articles, you can make appropriate choices. After all, you must take into account both product experience and user traffic.

    reply
    0
  • PHP中文网

    PHP中文网2017-06-12 09:21:43

    Then the question is, when you render the page on the server side and you request an article of tens of thousands of words, isn’t the amount of data even larger? Hundreds of thousands of words. A Chinese character is 2 bytes. Hundreds of thousands of words are only a few hundred KB = =How big can it be

    reply
    0
  • Cancelreply