kontent-ai / java-packages

Delivery Java SDK for Kontent.ai including examples for Spring, Gradle, Kotlin and Java Android app
https://kontent.ai/learn/tutorials/develop-apps/overview/?tech=java
MIT License
14 stars 28 forks source link

HttpClient connection management #8

Closed aweigold closed 7 years ago

aweigold commented 7 years ago

The default HttpClient probably only has 2 connections per host in it's pool. Create more adequate defaults as well as a pattern for customization.

See this link.

aweigold commented 7 years ago

I increased the default from 2 to 20, however have not put in a pattern for customization yet.

20 is a bit of a magic number... any thoughts @petrsvihlik ?

petrsvihlik commented 7 years ago

@aweigold What if there'll be 5k requests coming to the site? Why not set it to more? Are there any downsides?

aweigold commented 7 years ago

I almost set it to 100 for that reason @petrsvihlik ... The downside is someone shooting themselves in the foot with their CPU when they should be caching your responses... but that said, the OS should free the proc when the thread is blocking on an http response.

The default total pool size for the Apache HttpClient I'm using was 20, so I just carried over their thinking to the host limitation.

aweigold commented 7 years ago

I'm just going to check in a set method quick... that way there is a failsafe...

petrsvihlik commented 7 years ago

@aweigold all makes sense to me, i think we can close this one. thanks