On 7 Apr 2018, at 00:21, Michael Pog <smic...@gmail.com> wrote:I would like to maintain different connection pool size per destination host.Looks like the only way I can do it is create a separate HTTP Client for each destination host. Is it possible to create multiple HTTP Clients per host with different configurations? Is there a limit of something I need to watch for when it comes to that?
What would happen if I send a request to the same host:Port from two different WebClients on the same verticle? Would that still work?
--
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/1162ae5e-d7ee-421c-90d5-9ae3f5b2f7ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/db8d486b-46a7-4049-9d38-aa64dfca64df%40googlegroups.com.
On 9 Apr 2018, at 00:47, Michael Pog <smic...@gmail.com> wrote:Hi JulienYes I have.That does not scale.The event bus and the communication between threads adds extra overhead and latency, and it does not perform well.
Also A single request to my web server, can be transformed into 40-50 outbound requests. So having more HTTP server verticles than HTTP client ones, makes no sense at all.It would be great if at least WebClient could take InetAddress instead of hostname. (Just like AsynHttpClient does), or something like that which would allow pssing both IP address and hostname, and WebClient would maintain a pool per host and not per IP, but still use the provided IP address. I think at least that is doable and does not add any contention/overhead.
Having a shared connection pool among multiple Weclients, that indeed may be tricky, but ASAP AsyncHttpClient does have that and it performs relatively fine. At least having that option would be nice.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/ed7ae32d-4d02-4a6d-be77-bd833eedefd2%40googlegroups.com.
Map<String, WebClient> clientPool = ExpiringMap.builder()
.maxSize(webhookConnectionMaximumPoolSize)
.expiration(webhookConnectionPoolTtlSec, TimeUnit.SECONDS)
.<String, WebClient>asyncExpirationListener((k, c) -> c.close())
.build();
String urlAsKey = webhookBody.getString("domain") + ":" + webhookBody.getInteger("port") + webhookBody.getString("uri");
WebClient client = clientPool.get(urlAsKey);
if (client == null) {
WebClientOptions clientOptions = new WebClientOptions();
clientOptions.setSsl(webhookBody.getBoolean("ssl"));
clientOptions.setTrustAll(webhookBody.getBoolean("trustAll"));
client = WebClient.create(vertx, clientOptions);
clientPool.put(urlAsKey, client);
}
client
.post(...)
.as(BodyCodec.jsonObject())...
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/529f18d2-d155-4ec7-b066-b51168f0bd9d%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/0947bd0b-0726-4855-8181-c78290b9a8fd%40googlegroups.com.