title: How to load test an HTTP endpoint with FSharp Interactive
body: <p>What is the best what to load test a http endpoint from the FSharp interactive? For example I tried to load a <code>HelloWorld</code> Azure Function with the following:</p>
  
  <pre><code>open FSharp.Data
  async { 
      let url = "https://transactive.azurewebsites.net/api/HelloWorld"
      for i = 1 to 1000 do
          let! html = Http.AsyncRequestString(url)
          printfn "Invokation %i" i  } |&gt; Async.Start
  </code></pre>
  
  <p>Afer running this in the FSharp Interactive the AzureFunctions Live Log shows 12 TPS. Starting a second FSI results in 24 TPS. Doing this instead:</p>
  
  <pre><code>open FSharp.Data
  let makeAsync = async { 
      let url = "https://transactive.azurewebsites.net/api/HelloWorld"
      for i = 1 to 1000 do
          let! html = Http.AsyncRequestString(url)
          printfn "Invokation %i" i  }
  
  
  let a = [| for i in 1..5-&gt; makeAsync |]
  let results = a |&gt; Async.Parallel |&gt; Async.RunSynchronously
  </code></pre>
  
  <p>Results in 60TPS in the Azure Live Log (image). Interestingly up to a maximum of 5, every increase in the parallelism resulted in another 12TPS. Increasing the parallelism beyond 5 did not increase TPS. However starting a second FSI results in about 120TPS. </p>
  
  <p><a href="https://i.stack.imgur.com/Q5ypU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q5ypU.png" alt="Azure Function Live Log"></a></p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>What is going on? Why is 12 a magic number?</p></li>
  <li><p>What is the best way to drive a HTTP endpoint as hard as possible from a script running in a single FSI?</p></li>
  </ol>
  
  <p>My machine is a VM with 4 cores allocated and 10Gig RAM.</p>
  
  <p>In case someone wants to try things the function is still running (assuming it has not run into the <code>Daily Usage</code> Quota).</p>