Proactive C # item34: create a large-granularity web API

Source: Internet
Author: User

When we use web service or. net remoting, it is important to note that when objects are transmitted between local and remote machines, the transmission process costs a lot. For some operations that simply repeat and package local interfaces, we should not use them as remote APIs, so there will be no errors, but the efficiency is relatively low.

Our web interfaces should mainly transmit serialized documents or object sets between the client and the server. The client first performs logical processing and prepares data. This process does not need to communicate with the server. When the client prepares the data, it sends the entire document to the server; the same is true on the server. After the server processes all the content in the document, it returns it to the client.

For some data with long local operations and infrequent updates, we can use the visitor mode. First, each client obtains all necessary data from the server, at the same time, you can save your information on the server, and then the client can perform operations locally. when data is uploaded to the server, the server distributes the updated data, notify all relevant clients that the data has been updated. On the one hand, this can improve the efficiency of the client and avoid frequent communication with the server. On the other hand, it can ensure that the data processed by the customer is the latest data on the current server.

We hope that the communication frequency and load between the client and the server can be minimized, but these two goals are contradictory. We need to find a balance between the two, the result of the balance should be close to the middle of the two limits, rather than leaning towards either side.

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.