HttpClientOptions (default is true).
In this case connections will be pooled and re-used if there are pending HTTP requests waiting to get a connection,
otherwise they will be closed.--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/173e9017-9890-44e6-b1f2-332cc5cb74ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
HttpClientOptions (default is true). In this case connections will be pooled and re-used so long as the connection is still alive. The connection will stay alive and re-pooled until it is closed by the server.To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/6229243a-30be-4066-9684-a6102070c933%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/e9d08547-c01e-4cbc-9c4e-e0c5a255f1e1%40googlegroups.com.
The keep-alive is usually a tradeoff between keeping the connections around longer based on a guess how often connections are required or closing them to avoid keeping too many open handles around.
Browsers will keep the connections open for some time and the server can decide a timeout as well (this may be 5 or 15 seconds in apache for example).
I think the current implementation uses the timeout of the server (by just dropping the connection when the server closes it) and otherwise keep the connection open indefinitely (at least I think so, I have to check the code)
The simplest example to show that a client side keep alive can be beneficial is something like the following
while(true) {
sleep(2);
get("/status", ...);
}
when using a keepalive that only reuses connections when there are some pending will close the connection each time the get is finished and open a new one for the next request. Since the keep-alive timeout is probably at least 5 seconds if the connections are kept open between calls, it will all use just one tcp connection saving the overhead of routing and ssl.
On Wednesday, 10 May 2017 12:00:24 UTC+1, Alexander Lehmann wrote:The keep-alive is usually a tradeoff between keeping the connections around longer based on a guess how often connections are required or closing them to avoid keeping too many open handles around.
Browsers will keep the connections open for some time and the server can decide a timeout as well (this may be 5 or 15 seconds in apache for example).
I think the current implementation uses the timeout of the server (by just dropping the connection when the server closes it) and otherwise keep the connection open indefinitely (at least I think so, I have to check the code)
The simplest example to show that a client side keep alive can be beneficial is something like the following
while(true) {
sleep(2);
get("/status", ...);
}
when using a keepalive that only reuses connections when there are some pending will close the connection each time the get is finished and open a new one for the next request. Since the keep-alive timeout is probably at least 5 seconds if the connections are kept open between calls, it will all use just one tcp connection saving the overhead of routing and ssl.But I'm not sure it matters for most cases. Think of it is this way (this is for straight TCP, for SSL there's more overhead in connection setup)With the old behaviour, let's consider the cases.Let network round trip time = T (maybe up to a few 100 of ms depending on route)Let server connection timeout = S (500ms is common default)
I don’t remember having changed the behavior of this when I contributed to the client.
That being said both behavior are desirable, you might want to keep a connection a little in the pool before closing it to avoid recreating the connection but you want also to save resources if you don’t use them anymore.
On May 10, 2017, at 12:05 PM, Tim Fox <timv...@gmail.com> wrote:
Note, I'm not saying that's the best way to implement it, just how it used to implemented hence the comment :)
On Wednesday, 10 May 2017 09:43:35 UTC+1, Tim Fox wrote:That's how it _used_ to work (things may have changed since then in the implementation).The reasoning is simple: The point of keep alive is to reuse connections for better performance, but if you're sending requests so slowly there are no pending requests (i.e. requests go to the server and a response comes back before you send the next request) then you're going to obtain little or no performance improvement from using keep alive, so you may as well close the connection.BTW this is exactly the same behaviour as the node.js http client pool, from which the vert.x one was originally modelled.
On Tuesday, 9 May 2017 21:10:16 UTC+1, ad...@cs.miami.edu wrote:Hi,
In the docs I see this statement:
For pooling to occur, keep-alive must be true on theHttpClientOptions(default is true). In this case connections will be pooled and re-used if there are pending HTTP requests waiting to get a connection, otherwise they will be closed.
I would expect that the keep-alive would keep the connection alive for a period of time even if there are no pending HTTP requests. But this seems to close the connection immediately if there is not an immediate "next" request to be made. I thought the whole idea of a keep alive is to keep a connection alive for a short period of time "in-between" requests. But, this does not seem to be the case in the vert.x Http Client. Am I understanding the docs correctly?
Thanks,
-Adam--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
On Wednesday, 10 May 2017 12:19:22 UTC+1, Julien Viet wrote:I don’t remember having changed the behavior of this when I contributed to the client.I think it might have been changed before that, around Vert.x 2 time-frame.
That being said both behavior are desirable, you might want to keep a connection a little in the pool before closing it to avoid recreating the connection but you want also to save resources if you don’t use them anymore.
On May 10, 2017, at 12:05 PM, Tim Fox <timv...@gmail.com> wrote:
Note, I'm not saying that's the best way to implement it, just how it used to implemented hence the comment :)
On Wednesday, 10 May 2017 09:43:35 UTC+1, Tim Fox wrote:That's how it _used_ to work (things may have changed since then in the implementation).The reasoning is simple: The point of keep alive is to reuse connections for better performance, but if you're sending requests so slowly there are no pending requests (i.e. requests go to the server and a response comes back before you send the next request) then you're going to obtain little or no performance improvement from using keep alive, so you may as well close the connection.BTW this is exactly the same behaviour as the node.js http client pool, from which the vert.x one was originally modelled.
On Tuesday, 9 May 2017 21:10:16 UTC+1, ad...@cs.miami.edu wrote:Hi,
In the docs I see this statement:
For pooling to occur, keep-alive must be true on theHttpClientOptions(default is true). In this case connections will be pooled and re-used if there are pending HTTP requests waiting to get a connection, otherwise they will be closed.
I would expect that the keep-alive would keep the connection alive for a period of time even if there are no pending HTTP requests. But this seems to close the connection immediately if there is not an immediate "next" request to be made. I thought the whole idea of a keep alive is to keep a connection alive for a short period of time "in-between" requests. But, this does not seem to be the case in the vert.x Http Client. Am I understanding the docs correctly?
Thanks,
-Adam--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f08bfc95-bd60-44fc-841f-6f0bfa0935bd%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/78ac69ef-0687-4db7-a0ad-51f071822e08%40googlegroups.com.
Ok, that works, however that timeout is applied to all phases of the http protocol, which means that the client will also close the connection when the servers takes more than n seconds to produce a response, which is not what we want.
I guess what is necessary is different timeouts in the different phases of the request or when the connection is idle.
This is not the same as a network timeout on the connection as this is applied to any phase of the connection.
For the server, this means that when a request is finished and the preconditions of keepalive are satisfied, the connection is kept open by the server
until it is either closed by the client or a wait time has passed (in httpd apache that is 15 or 5 seconds, but that could be configurable). If the preconditions are not satisfied, the connection is closed immediately, e.g. when the client has sent a Connection: close header or uses HTTP/1.0.
For the client, this means that when a request is finished and the server has signified that keepalive is available, the connection is kept open until it is closed by the server or a wait time has passed or if the server sent a Connection header with a wait time limit, the client can close the connection when this time has expired (whichever is smaller).
None of these things are absolutely required, for example it would be ok to keep the client connection open until the server closes the connection (though that might use up the pool connections if connections to different servers are kept open indefinitely) or the old behaviour of using the keepalive only when requests are pending would be possible as well.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/29da754b-081c-401b-9733-cefb277bc9f6%40googlegroups.com.