How the API outputs large amounts of data JSON data in a timely manner

Source: Internet
Author: User
In doing a Api,app end want to extract the brief data to cache on the phone side, so designed an interface to provide to the app to pick up,

After testing, the JSON format of the packet around 2M (as thin as possible and do the serialization process), resulting in a response time of about 10 seconds, this is not ideal, but also try to get too much page, but this increases the number of connections, is not ideal, decided to use one time to get the solution, so I would like to ask how to optimize the output of this data, such as the title mentioned in the timely output, but did not get past I am not sure whether this can guarantee the legitimacy and operability of JSON data. Suggestions are also welcome if there are other options.

Reply content:

In doing a Api,app end want to extract the brief data to cache on the phone side, so designed an interface to provide to the app to pick up,

After testing, the JSON format of the packet around 2M (as thin as possible and do the serialization process), resulting in a response time of about 10 seconds, this is not ideal, but also try to get too much page, but this increases the number of connections, is not ideal, decided to use one time to get the solution, so I would like to ask how to optimize the output of this data, such as the title mentioned in the timely output, but did not get past I am not sure whether this can guarantee the legitimacy and operability of JSON data. Suggestions are also welcome if there are other options.

Did you go back to the test with Redis or Memcahce?

This situation try gzip may have unexpected effect

If it is an efficiency problem to generate data, it is recommended to find a caching scheme

Now that you've used the app, use the app-side computing power
Request binary data back from the server, this data performs text compression-text compression is amazing oh, especially formatted data
Extract the data back to the JSON format after you have obtained it locally
JSON field name both parties agreed, as short as possible ~ ~ ~

Subsequent requests to obtain incremental or changed data can be

Compress, use MD5 to ensure file integrity, use GET request if business allows.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.