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.