hprose / hprose-java

Hprose is a cross-language RPC. This project is Hprose 2.0 for Java
MIT License
551 stars 187 forks source link

hprose RPC protocol speed #31

Open danielsawan opened 6 years ago

danielsawan commented 6 years ago

Hi there

I made some test in order to benchmark hprose RPC protocol and i was very surprised to see that it is slower then making an http request.

The test i made is really simple i just wrote a hello world http method that answer "hello" to an http get and wrote a client that call it 100 times.

Then i wrote a hrpose server listening on TCP having a helloworld method and call it from an hprose client 100 times.

I monitoring the execution time of both protocol and HTTP protocol win all the time expect when the number of call is above 1000.

I was exepecting that a self made protocole was quicker then HTTP.

Did i made something wrong here ?

andot commented 6 years ago

I don't know what's wrong, but on my computer, http get on tomcat: 2000-3000qps, and tcp hprose server: 80000-100000qps.

danielsawan commented 6 years ago

can you please try to put your remote method on another host then localhost ? In my test the client was on localhost but both serveur (http, hprose) was on a remote host. So the traffic had to go threw TCP like a prod context.

andot commented 6 years ago

If you use TCP, you can use setFullDuplex method to set the fullDuplex property to true on the client. It will be faster than the default setting.

danielsawan commented 6 years ago

The change is not hudge. Here is the results i get

10 requests : duration hpro : 175899988 duration http : 82985343 HTTP WIN

100 requests : duration hpro : 783401527 duration http : 716310436 HTTP WIN

500 requests : duration hpro : 3416468571 duration http : 3536256223 HPROSE WIN

1000 requests : duration hpro : 6644799171 duration http : 6926884271 HPROSE WIN

As i wrote before for a little number of request HTTP seems to be faster (real world situation) but when we loop over hundred of request then Hprose seems to be faster. I guess it is because HTTP Open & Close ressources for each call while Hprose let the connection Opened. But still in my little test HTTP seems to be faster.

andot commented 6 years ago

My test is 1 client, 40 threads, 25000 requests on each thread.

wu-sheng commented 6 years ago

@andot I think @danielsawan 's tests bring some important info. Limited requests per thread/connection seem more important to me. I suggest you should dive in to find out what is really happening in those cases.