@@ -130,8 +130,15 @@ To configure the SDK you need to provide required properties
130130| --------------------------- | ------------------- | ------------------------------ | -------- |
131131| io.getstream.chat.apiKey | STREAM_KEY | - | Yes |
132132| io.getstream.chat.apiSecret | STREAM_SECRET | - | Yes |
133- | io.getstream.chat.timeout | STREAM_CHAT_TIMEOUT | 10000 | No |
133+ | io.getstream.chat.timeout | STREAM_CHAT_TIMEOUT | 20000 | No |
134+ | io.getstream.chat.connectTimeout | STREAM_CHAT_CONNECT_TIMEOUT | 20000 | No |
135+ | io.getstream.chat.readTimeout | STREAM_CHAT_READ_TIMEOUT | 20000 | No |
136+ | io.getstream.chat.writeTimeout | STREAM_CHAT_WRITE_TIMEOUT | 20000 | No |
134137| io.getstream.chat.url | STREAM_CHAT_URL | https://chat.stream-io-api.com | No |
138+ | io.getstream.chat.connectionPool.maxIdleConnections | STREAM_CHAT_CONNECTION_POOL_MAX_IDLE_CONNECTIONS | 10 | No |
139+ | io.getstream.chat.connectionPool.keepAliveDurationMs | STREAM_CHAT_CONNECTION_POOL_KEEP_ALIVE_DURATION_MS | 118000 | No |
140+ | io.getstream.chat.dispatcher.maxRequests | STREAM_CHAT_DISPATCHER_MAX_REQUESTS | 128 | No |
141+ | io.getstream.chat.dispatcher.maxRequestsPerHost | STREAM_CHAT_DISPATCHER_MAX_REQUESTS_PER_HOST | 10 | No |
135142
136143You can also use your own CDN by creating an implementation of FileHandler and setting it this way
137144
@@ -141,6 +148,67 @@ Message.fileHandlerClass = MyFileHandler.class
141148
142149All setup must be done prior to any request to the API.
143150
151+ You can also tune the underlying OkHttp connection pool explicitly:
152+
153+ ``` java
154+ var properties = new Properties ();
155+ properties. put(DefaultClient . API_KEY_PROP_NAME , " <api-key>" );
156+ properties. put(DefaultClient . API_SECRET_PROP_NAME , " <api-secret>" );
157+ properties. put(DefaultClient . DISPATCHER_MAX_REQUESTS_PROP_NAME , " 128" );
158+ properties. put(DefaultClient . DISPATCHER_MAX_REQUESTS_PER_HOST_PROP_NAME , " 32" );
159+ properties. put(DefaultClient . CONNECTION_POOL_MAX_IDLE_CONNECTIONS_PROP_NAME , " 20" );
160+ properties. put(DefaultClient . CONNECTION_POOL_KEEP_ALIVE_DURATION_PROP_NAME , " 59000" );
161+ properties. put(DefaultClient . API_CONNECT_TIMEOUT_PROP_NAME , " 10000" );
162+ properties. put(DefaultClient . API_READ_TIMEOUT_PROP_NAME , " 30000" );
163+ properties. put(DefaultClient . API_WRITE_TIMEOUT_PROP_NAME , " 30000" );
164+ properties. put(DefaultClient . API_TIMEOUT_PROP_NAME , " 30000" );
165+
166+ var client = new DefaultClient (properties);
167+ client. setDispatcher(128 , 32 );
168+ client. setConnectionPool(20 , Duration . ofSeconds(59 ));
169+ client. setTimeouts(
170+ Duration . ofSeconds(10 ),
171+ Duration . ofSeconds(30 ),
172+ Duration . ofSeconds(30 ),
173+ Duration . ofSeconds(30 ));
174+ DefaultClient . setInstance(client);
175+ ```
176+
177+ Or configure the same values through options:
178+
179+ ``` java
180+ var options =
181+ DefaultClient . HttpClientOptions . builder()
182+ .dispatcher(128 , 32 )
183+ .connectionPool(20 , Duration . ofSeconds(59 ))
184+ .connectTimeout(Duration . ofSeconds(10 ))
185+ .readTimeout(Duration . ofSeconds(30 ))
186+ .writeTimeout(Duration . ofSeconds(30 ))
187+ .callTimeout(Duration . ofSeconds(30 ))
188+ .build();
189+
190+ var client = new DefaultClient (properties, options);
191+ ```
192+
193+ ### High traffic
194+
195+ For high traffic backends, a good starting point is:
196+
197+ ``` java
198+ var options =
199+ DefaultClient . HttpClientOptions . builder()
200+ .dispatcher(128 , 32 )
201+ .connectionPool(20 , Duration . ofSeconds(59 ))
202+ .connectTimeout(Duration . ofSeconds(10 ))
203+ .readTimeout(Duration . ofSeconds(30 ))
204+ .writeTimeout(Duration . ofSeconds(30 ))
205+ .callTimeout(Duration . ofSeconds(30 ))
206+ .build();
207+ ```
208+
209+ Start there and load test. In practice, ` dispatcher.maxRequests ` and
210+ ` dispatcher.maxRequestsPerHost ` usually affect throughput more than connection-pool size.
211+
144212## Print Chat app configuration
145213
146214<table >
0 commit comments