Hello,
I am writing an app which accesses a REST api. The documentation says this.
Connection Limits
To provide equal resources to all clients, we recommend limiting both
the number of new connections per second, and the number of requests per
second made on a persistent connection (see above/below).
For new connections, we recommend you limit this to twice per second
(2/s). Establishing a new TCP and SSL connection is expensive for both
client and server. To allow a better experience, using a persistent
connection will allow more requests to be performed on an established
connection.
For an established connection, we recommend limiting this to one hundred
per second (100/s). Please see following section on persistent
connections to learn how to maintain a connection once it is established.
HTTP Persistent Connection
This keeps the underlying TCP connection active for multiple
requests/responses. Subsequent requests will result in reduced latency
as the TCP handshaking process is no longer required.
If you are using an HTTP 1.0 client, ensure it supports the keep-alive
directive and submit the header |Connection: Keep-Alive| with your request.
Keep-Alive is part of the protocol in HTTP 1.1 and enabled by default on
compliant clients. However, you will have to ensure your implementation
does not set the connection header to other values.
I do not know how to reuse a connection.
I see in ZnClient #canReuseConnection and #connectionReuseTimeout.
Is the timeout from connection time or last request or access time?
Does that handle everything automatically for me?
I will be accessing this api multiple times a minute, sometimes multiple
times a second for almost all the time.
How long can I keep a persistent connection open?
What are best practices?
Any help and wisdom greatly appreciated.
Thanks.
Jimmie