In the use of Web Services,. NET remote calls or to AzureProgramThe most time-consuming is the transmission process with the remote server. If the local API is simply encapsulated, it becomes an API for remote use. This feature does not have problems, but is inefficient. The finer the API granularity, the more additional events are required to wait for data to return.
When creating a web-based service, the communication process between the client and the server should be the same as sending a fax: the client can work for a period of time without having to contact the server. Then, after all the data required for one communication is in place, the client will send all the information to the server at one time. The server should also do the same: when sending data from the server to the client, all the content should be sent at one time so that the client can complete all the current tasks.
Now let's assume that the system has only one server, and there are more than 1 million customers. Assume that each customer made an average of 15 orders in the year of last year. Each telemarketing call operates a client during the ordering process and needs to query or create a customer when answering the call. How can we design a series of objects that are most effective on the client and server? Here, it is unrealistic to send each customer and each order to the client at a time: there are too many data records corresponding to 1 million of customers and 15 million of orders.
When designing a web service that communicates with remote computers, we hope to reduce the frequency of communication and the amount of data transmitted during each communication. The two goals are not both the fish and the bear's paw, and we must strike a balance between them. We should try not to go to two extremes, but we can select a smaller number of communications and try to transmit more data at a time.