Calls to requestToken are sync in the SDK, and use a singleton executor in the SyncHttpScheduler. This means that requests will queue behind each other.
If you have 50 threads creating tokens, the executor can only do 1 thread worth of throughput.
Also related, adding more threads creating tokens means that all threads end up taking longer (not just the later threads taking linearly longer).
Token id: 12 with time since start 5123ms
Token id: 4 with time since start 5122ms
Token id: 14 with time since start 5122ms
Token id: 26 with time since start 5122ms
Token id: 39 with time since start 5121ms
Token id: 16 with time since start 5100ms
Token id: 1 with time since start 5124ms
Token id: 7 with time since start 5100ms
Token id: 18 with time since start 5123ms
Token id: 30 with time since start 5112ms
|
String tokenPath = "/keys/" + signedTokenRequest.keyName + "/requestToken"; |
|
return HttpHelpers.postSync(ably.http, tokenPath, null, null, new HttpUtils.JsonRequestBody(signedTokenRequest.asJsonElement().toString()), new HttpCore.ResponseHandler<TokenDetails>() { |
|
public class SyncHttpScheduler extends HttpScheduler { |
┆Issue is synchronized with this Jira Task by Unito
Calls to
requestTokenare sync in the SDK, and use a singleton executor in the SyncHttpScheduler. This means that requests will queue behind each other.If you have 50 threads creating tokens, the executor can only do 1 thread worth of throughput.
Also related, adding more threads creating tokens means that all threads end up taking longer (not just the later threads taking linearly longer).
ably-java/lib/src/main/java/io/ably/lib/rest/Auth.java
Lines 850 to 851 in b2e6b22
ably-java/lib/src/main/java/io/ably/lib/http/SyncHttpScheduler.java
Line 8 in b2e6b22
┆Issue is synchronized with this Jira Task by Unito