public class SimpleHttpClientTest {
public static void main(String[] args) throws Exception { Vertx vertx = Vertx.vertx(); System.out.println("Try #1"); createHttpClientAndMakeRequest(vertx); Thread.sleep(1000); System.out.println("Try #2"); createHttpClientAndMakeRequest(vertx); Thread.sleep(1000); System.out.println("Try #3"); createHttpClientAndMakeRequest(vertx); } public static void createHttpClientAndMakeRequest(Vertx vertx) { HttpClientOptions options = new HttpClientOptions().setKeepAlive(false); long t0 = System.currentTimeMillis(); HttpClient client = vertx.createHttpClient(options); System.out.println("HttpClient created in " + (System.currentTimeMillis() - t0)); long t1 = System.currentTimeMillis(); io.vertx.core.http.HttpClientRequest request = client.getAbs("http://my_local_server"); request.handler(response -> { System.out.println("Got response in " + (System.currentTimeMillis() - t1)); }); request.end(); }}Try #1
HttpClient created in 173
Got response in 298
Try #2
HttpClient created in 0
Got response in 92
Try #3
HttpClient created in 0
Got response in 42Try #1HttpClient created in 11Got response in 168Try #2HttpClient created in 0Got response in 49Try #3HttpClient created in 0Got response in 67static { ArrayList<String> suite = new ArrayList<>(); try { SSLContext context = SSLContext.getInstance("TLS"); // takes around 35ms for me context.init(null, null, null); // takes around 30 ms for me SSLEngine engine = context.createSSLEngine(); // takes around 100ms for me Collections.addAll(suite, engine.getEnabledCipherSuites()); } catch (Throwable e) { suite = null; } DEFAULT_JDK_CIPHER_SUITE = suite != null ? Collections.unmodifiableList(suite) : null; }--
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/d85c94dc-4541-4fbb-bf1c-7d4cb213c8d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Julien,Yes, I usually do create a single HttpClient and re-use it.The reason why I created multiple HttpClients in my example is to show that only the first one was slow to be created.Is this "slow" creation normal? And what about the slow first request?Maybe it's generally not an issue in a Vertx Application if there's a bit of warm up time. I just wanted to check if that was a normal behavior.