Upload
huqiu-liao
View
471
Download
0
Embed Size (px)
Citation preview
Build RPC Service for PHP@liaohuqiu_
Why RPCHow to design a RPC serviceContentImplements
Script: Easy to develop / deployLife Cycle: safe to run, easy to code, easy to hire.the Good
PerformanceSystem statusthe Bad
PHPRPC+
ICE / Thrift / YAF Current solutions
Network ProtocolSerialize ProtocolDesign RPC ServiceMessage / RPC ProtocolException / Log / Debug / PerformanceCommunication mechanism
Communication mechanismhalf-duplex
UDPNetwork ProtocolTCP
JSON / MsgPack / BinPack vs Google PBSerialize ProtocolSimple data type vs Object
QueryAnswerCloseWelcomeMessage & Call Flow
Message Header
Query Body
Answer Body
Data for exception
2015-08-27 12:24:43,692 DEBUG ('127.0.0.1', 33441): message received: proxy.Query((2, 'android-gems', 'index_data', []))2015-08-27 12:24:43,692 DEBUG handle_normal_servant: proxy.Query((2, 'android-gems', 'index_data', []))2015-08-27 12:24:43,692 DEBUG ('127.0.0.1', 33441): reply answer: proxy.Answer((2, 0, {'libs': [], 'un_review_count': 1, 'users': []}))2015-08-27 12:24:43,723 DEBUG ('127.0.0.1', 33441): connection has been closed by client.2015-08-27 12:24:43,723 DEBUG ('127.0.0.1', 33441): close connection2015-08-27 12:24:43,723 DEBUG ('127.0.0.1', 33441): answer fiber stopLog
2015-08-27 12:25:06,469 DEBUG ('127.0.0.1', 33452): reply answer: proxy.Answer((3, 100, {'exception': 'MethodNotFound', 'code': 1, 'raiser': u'android-gems@tcp:0.0.0.0:2099', 'message': u'servant android-gems do no have method index_data1 in adapter android-gems@tcp:0.0.0.0:2099'}))Exception log
JavaImplementsPython: C++PHPhttps://github.com/liaohuqiu/cube-rpc-pythonClient only. https://github.com/liaohuqiu/cube-phpOpen source in process
PerformancePythonC++Java
Real world examples
Android Gems Top User
ATA
Q & A