Main process promotion strategy (5): Comparison of HTTP protocol and binary protocol

In the previous article, " Main Process Promotion Strategy (4): TCP, Message Subcontracting and Protocol Design ", I talked about some topics of protocol design. Here, I will add the comparison between HTTP protocol and binary protocol.

 

The HTTP protocol is a text protocol and a Name-Based protocol, in terms of these two aspects.

 

Text Protocol vs Binary Protocol

Features of the text protocol:

    easy for people

    Easy to read, understand, debug, construct

    The analysis is complex and redundant

    Character escaping needs to be considered

 

Features of the binary protocol:

    easy to machine

 

Name-Based vs Position-Based

Features of Name-Based Protocol:

    Protocol fields are identified by Name

    The protocol field is position independent

    The protocol field can be defaulted

    It is convenient to add a new protocol field

    Parsing is complex

    Character escaping needs to be considered

 

Features of Position-Based Protocol:

    Each protocol field has a specific location

    Adding protocol fields requires protocol version management ( protobuf is good)

    More efficient parsing

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326453144&siteId=291194637