天天看點

rpc架構之avro 學習 1 - hello world

rpc架構之avro 學習 1 - hello world

avro-client子產品中的pom.xml參考以下内容:

rpc架構之avro 學習 1 - hello world
rpc架構之avro 學習 1 - hello world

View Code

一、定義檔案示例

Person.avsc

QueryParameter.avsc

DemoService.avdl

二、服務端

DemoServiceImpl.java

AvroServer.java

三、用戶端

AvroClient.java

 avro 100000 次RPC調用,耗時:18617毫秒,平均5371次/秒

注:雖然很多關于thrift、avro的性能評測文章提到avro性能不輸于thrift,但就本文的示例而言,在同一台筆記本上,avro的性能隻有thrift的約1/2.

參考文章:

<a href="https://github.com/phunt/avro-rpc-quickstart" target="_blank">https://github.com/phunt/avro-rpc-quickstart</a>

<a href="http://avro.apache.org/docs/current/spec.html#Protocol+Declaration" target="_blank">http://avro.apache.org/docs/current/spec.html#Protocol+Declaration</a>

<a href="http://avro.apache.org/docs/current/idl.html" target="_blank">http://avro.apache.org/docs/current/idl.html</a>

<a href="http://avro.apache.org/docs/current/gettingstartedjava.html" target="_blank">http://avro.apache.org/docs/current/gettingstartedjava.html</a>

<a href="http://jishu.zol.com.cn/3593.html" target="_blank">Apache Avro 與 Thrift 比較</a>