title: Get FastAPI to handle requests in parallel
body: <p>Here is my trivial <code>fastapi</code> app:</p>
  <pre><code>from datetime import datetime
  import asyncio
  
  import uvicorn
  from fastapi import FastAPI
  
  
  app = FastAPI()
  
  @app.get(&quot;/delayed&quot;)
  async def get_delayed():
      started = datetime.now()
      print(f&quot;Starting at: {started}&quot;)
      await asyncio.sleep(10)
      ended = datetime.now()
      print(f&quot;Ending at: {ended}&quot;)
      return {&quot;started&quot;: f&quot;{started}&quot;, &quot;ended&quot;: f&quot;{ended}&quot;}
  
  if __name__ == &quot;__main__&quot;:
      uvicorn.run(&quot;fastapitest.main:app&quot;, host=&quot;0.0.0.0&quot;, port=8000, reload=True, workers=2)
  </code></pre>
  <p>When I make 2 consecutive calls to it, the code in the function for the second one doesn't start executing until the first request finishes, producing an output like:</p>
  <pre><code>Starting at: 2021-09-17 14:52:40.317915
  Ending at: 2021-09-17 14:52:50.321557
  INFO:     127.0.0.1:58539 - &quot;GET /delayed HTTP/1.1&quot; 200 OK
  Starting at: 2021-09-17 14:52:50.328359
  Ending at: 2021-09-17 14:53:00.333032
  INFO:     127.0.0.1:58539 - &quot;GET /delayed HTTP/1.1&quot; 200 OK
  </code></pre>
  <p>Given that the function is marked <code>async</code> and I am <code>await</code>ing the <code>sleep</code>, I would expect a different output, like:</p>
  <pre><code>Starting at: ...
  Starting at: ...
  Ending at: ...
  INFO:     127.0.0.1:58539 - &quot;GET /delayed HTTP/1.1&quot; 200 OK
  Ending at: ...
  INFO:     127.0.0.1:58539 - &quot;GET /delayed HTTP/1.1&quot; 200 OK
  </code></pre>
  <p>[for the calls
  I just opened up 2 browser tabs at localhost:8000/delayed ]</p>
  <p>What am I missing?</p>