Four commonly used messaging protocol designed to compare the merits of way

C structure:

Package poor scalability
packet length is fixed, the size limits, not much less row, the data packet is too large
int is not common to use cross-platform int32_t
message content type restrictions pod by

Serialization:

You can define very complex structure
limits the server client with C ++, all using the same library
packet size remains large

json:

Compact message, greatly optimized packet size, the compression ratio is very high
visualization good, the package contents can be printed directly

protobuf:

Message documentation easier to understand, you can plan to fill the numerical protocol
packet size compared with json, there has been more optimized parsing speed also improves
the data try not to use protobuf, visualization bad; better use json , multi-language support

In summary json with the best mode designs message data packet is the server and client communications protocols recommended protobuf, stored in the database server

Published 146 original articles · won praise 34 · views 5096

Guess you like

Origin blog.csdn.net/qq_39885372/article/details/104084083