Service interface, select the rpc or http?

Communication from the content / function point of view

http applied to the web environment, rpc used in distributed scheduling
is not much different from a functional point of view, rpc combination of communication and messaging middleware implement distributed scheduling in many cases

From the usage point of view
both c / s structure, no big difference

From the point of view to achieve
the type of underlying protocol

From a performance point of view
1, it is heard rpc long link, http is a three-way handshake.
Although long link, the cost can be reduced tcp, it will import the new relative disadvantage, whether the number of connections will have restrictions?

2, if rpc performance than http, nothing more than a multi-socket connection three times. If the combination of non-blocking io http server (for example, tornado), these three really nothing connection overhead consumption.
Of course, the network will have little consumption. Non-blocking io rpc server performance gap can be leveled with http

From the link costs, compare performance issues, this is wrong, both in solving different issues, there is no need to tangle at all on this issue. Please read the following

Conceptually
rpc remote call
http Hypertext Transfer Protocol

How to choose?
1, think about this question, we should use the simplest way, and that protocol designers will choose the best way to solve the problems facing it (after all, the agreement represents accepted), we only focus on what problems it solves.
rpc solve the problem? Remote call. "Call" belongs among internal procedures. The total can not just call the pass simple parameters, will involve the target sequence,
the object is in the development of the code is never used two sets of bars, server and client is likely to be a component belong together.

2, number of connections should not be a "call" things to consider. After you create a global connection, you will not often create a connection. If rpc as a service, the scene of frequent connection is not suitable for it

Summary
1, c s close relationship with the degree
rpc remote calls between the internal part of the program, cs close.
http, suitable for different components, cs independent relationship.

2, the number of connections
rpc call to call, the scene of frequent connection it is not suitable
web environment applications http, and this is the scene of frequent connection

Guess you like

Origin www.cnblogs.com/Jansens520/p/11646258.html