Several principles of network communication Service design

Source: Internet
Author: User
9. The current business processing thread needs to contain heavy Work_socket objects, network processing and business mix in a
, the coupling is stronger, the network is the network, the network is the data channel, the business is the business, the business utilizes the data channel
General principles, so that business developers basically do not need to know how the network communication, development can be reduced,
Business developers will not be able to directly interact with the client, you can effectively mask the error, it is recommended that the business processing layer is only
Retains a lightweight connection ID structure, rather than a complete socket object, otherwise the business processing layer can be
With arbitrary send data, bad control; The network processing layer provides an excuse for sending data: Send (char *buff,
struct connectid); When the data is sent to the network layer, the network layer is responsible for sending it. This is a bit of the daytime code.
Suggestions, for future design for reference. Now this model has a high maturity, stable first use well.

10. There is also a principle that communication is communication and that agreement is an agreement. This is a very good performance in our framework.
Generally speaking, communication is only responsible for the transmission of data, what data transfer is controlled by the protocol, the integrity of the data is also
Controlled by agreement. such as a TCP connection, is a communication, what data is transmitted by the Protocol to control, protocol
What data is assembled inside the package is what data. Once the data received, the data is not complete, is a complete package, also
is a multiple full package, controlled by the protocol. If you have an extra half packet, merge the data the next time you complete it. So so
is to receive a batch of data, the data sent to the specified protocol resolution, parse successfully, to carry out the unpacking, the demolition of a good data
Packages are sent to the business layer to be processed. In this way, communication and protocols are connected, differentiated, and they can be separated into layered designs.

Whether the socket can be reused, whether multiple business packets can be sent on a connection, and avoid short connections,
Especially mobile Internet or large concurrent business, the cost of establishing a network connection is very high (slow).

12. Whether the network data transceiver support asynchronous transceiver, receive and send separate design and implementation, the time can be sent, because
The network channel is a dual-channel (TCP,UDP).

13. Protocol resolution can be configured, a process to support a number of protocols, flexible loading.

14. Service discovery; Fault migration, node removal, configuration center, update automation; interface invocation time-consuming; Business Interface error Statistics

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.