title: Count number of requests with global variable using FastAPI
body: <p>I want to count the number of requests in a specific URL path.</p>
  <pre><code>app = FastAPI()
  counter = 0
  
  @app.get(&quot;/do_something&quot;)
  async def do_something():
      global counter
      counter += 1
      return {&quot;message&quot;: &quot;Hello World&quot;}
  </code></pre>
  <p>Is this code ok?
  The counter should be thread safe? asincio safe?
  Is that the right way to count requests (Without DB)?
  Is there a meaning for the &quot;async&quot; in the &quot;do_something&quot; function in this situation?
  And how to make it work with several workers?</p>