Restful 基于 Http 进行通信。html
RPC通信git
最佳实践:对内一些性能要求高的场合用 RPC,对内其余场合以及对外用 Rest。好比 web 服务器和视频转码服务器之间通信能够用 restful 就够了,转帐接口用 RPC 性能会更高 一些。github
以上参考:老杨的课件。web
Thrift是一个跨语言通讯的服务框架,不一样语言开发的程序能够经过Thrift来进行通讯。apache
下载:http://www.apache.org/dyn/closer.cgi?path=/thrift/0.11.0/thrift-0.11.0.exe服务器
把 thrift-***.exe 解压到磁盘,更名为 thrift.exe(用起来方便一些)restful
编写 **.thrift 文件(IDL)框架
根据IDL,自动生成对应的语言代码:性能
thrift -gen csharp f:\netcore\Thrifts\school.thriftrest
https://github.com/tianbogit/ThriftDemo
//关联处理器与服务的实现 TProcessor helloProcessor = new HelloService.Processor(new MyHelloService()); TProcessor schoolProcessor = new SchoolService.Processor(new MySchoolService()); //建立服务端对象 var processorMulti = new TMultiplexedProcessor(); processorMulti.RegisterProcessor("helloService", helloProcessor); processorMulti.RegisterProcessor("schoolService", schoolProcessor); TServer server = new TThreadPoolServer(processorMulti, serverTransport, new TTransportFactory(), factory);
Thrift总结:https://www.cnblogs.com/zhangweizhong/category/1006119.html
实现Thrift链接池:http://www.cnblogs.com/walkerwang/archive/2012/10/08/2715735.html
[1]“Thirft框架介绍”
[2]“Thrift使用指南”
[3]“使用Thrift RPC编写程序”
[4]“让Thrift支持双向通讯”
[5]“浅谈Thrift内部实现原理“