title: First call to Snowflake from .NET Connector is very slow
body: <p>I am currently checking the latency when connecting to Snowflake from the <a href="https://github.com/snowflakedb/snowflake-connector-net" rel="nofollow noreferrer">Snowflake Connector for .NET library</a>. I have noticed that the first call when running the console application is some form of a &quot;cold start&quot;, where it usually takes ~1 sec to connect for this call, compared to ~70 ms for subsequent calls. The graph below shows this clearer.</p>
  <p><a href="https://i.stack.imgur.com/yMBZ5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yMBZ5.png" alt="enter image description here" /></a></p>
  <p>My question is: why is this?</p>
  <p>I have tried checking the code in the snowflake connector module, but the trail seems to end with an HTTP call: <code>var response = await Snowflake.Data.Core.HttpUtil.getHttpClient().SendAsync(request, linkedCts.Token).ConfigureAwait(false);</code>. I presume that the initial latency could have something to do with how HTTP works, but I don't know if that's true. Anyways, I think my webapp won't be affected by this initial delay, since it's server based - and my tests for this scenario shows that the delay only affects the first REST call, not the subsequent ones.</p>
  <p>Oh, and here's the code I'm running to check the delay (with for loops and stuff omitted):</p>
  <pre><code>Stopwatch latencyConnectionWatch;
  using (Snowflake.Data.Client.SnowflakeDbConnection conn = new Snowflake.Data.Client.SnowflakeDbConnection())
  {
      conn.ConnectionString = connectionString;
      latencyConnectionWatch = Stopwatch.StartNew();
      conn.Open();
      latencyConnectionWatch.Stop();
      conn.Close();
  }
  </code></pre>