Android HttpClient performance

后端 未结 2 1323
梦如初夏
梦如初夏 2021-02-02 02:44

I developing android app which uses a lot of http requests to web service. At first, I was creating a new HttpClient instance before every request. To increase performance I try

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 03:31

    It is all very simple. HttpClient per default allows only two concurrent connections to the same target host as required by the HTTP specification. So, effectively your worker threads spend most of their execution time blocked waiting for those two connections to become available.

    You should increase the 'max connections per route' limit to reduce / eliminate worker thread contention.

    You might also want to check out the benchmark used by Apache HttpComponents project to measure performance of HttpClient.

    http://wiki.apache.org/HttpComponents/HttpClient3vsHttpClient4vsHttpCore

提交回复
热议问题