很多同学想知道rpc是什么,下面是小编整理的相关内容,希望对大家有所帮助!
Rpc是什么
RPC(Remote Procedure Call)是远程过程调用,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。
RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据。在OSI网络通信模型中,RPC跨越了传输层和应用层。RPC使得开发包括网络分布式多程序在内的应用程序更加容易。
RPC采用客户机/服务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。首先,客户机调用进程发送一个有进程参数的调用信息到服务进程,然后等待应答信息。
Restful和RPC是什么关系
这两个不是互斥的,HTTP是不是RPC完全取决于client的具体形式。传统的RPC一般是基于二进制协议的,client发个二进制包过来(然后阻塞),server处理完回复一个包,client收到后醒来。在二进制协议中一般可以在包中加个id来指明回复和请求的对应关系,这样我们就能在一个tcp连接上同时发起多个请求和回复。HTTP这种文本协议也可以加id,但由于一些原因(Content-Length可能缺失),即使加了id也做不到一个连接上同时传多个HTTP消息,所以HTTP协议一般会和server保持多个连接,每个连接上同时最多只有一个HTTP消息。此种”连接池“方式即为HTTP中的”Keep-alive“。所以即使在HTTP上(或任何协议上),我们仍然可以做到高效地发送一个请求过去,阻塞,等待server处理完后,再醒来。这不就是RPC么。所以这儿的选择更多是平衡功能和性能。一般来说,面向终端用户的尽量用Restful HTTP。原因是认知广,直观,编程语言都支持HTTP(包括shell,这样调试起来方便),性能不是那么重要,方便用户share链接。而面向内部系统的话如果机器不多也可以考虑用Restful HTTP,如果机器很多还是尽量用二进制的RPC吧,毕竟性能差距还是很大的。
评论
Great, thanks for sharing this article post. Thanks Again. Awesome. Loree Jourdain Bastian
Pretty! This has been an extremely wonderful post. Thanks for providing this information. Jaimie Mik
My developer is trying to convince me to move to .net from PHP. Lari Panchito Kauffman
You made some decent points there. I did a search on the topic and found most persons will consent w
oVbhzPBJMT
There is definately a great deal to find out about this topic. I like all the points you made. Reeba
Very nice pattern and wonderful content material , nothing at all else we want : D. Marji Orran Tere
Well I really liked reading it. This subject offered by you is very effective for good planning. Han