title: Callback vs Await Performance in Express
body: <p>People say that <code>async/await</code> is just another way to write callbacks for promises. However, I feel as though they are not interchangeable; in fact, callbacks would be better in Express because it returns the result to the user right away. Is this correct?</p>
  
  <p>In the following example, let's say we don't care about the result of <code>doSomethingAsync()</code>, but want to redirect right away. Here, we use <code>await</code>.</p>
  
  <pre><code>router.get('/register', async (req, res) =&gt; {
      res.redirect('/')           
      await doSomethingAsync()
      console.log(1)
  }
  
  router.get('/', (req, res) =&gt; {
      console.log(2)
      ...
  }
  </code></pre>
  
  <p>This would print out <code>1</code>, then <code>2</code>, meaning that we won't be able to exit the <code>/register</code> handler and redirect unless the async function finishes.</p>
  
  <p>In the below version, we use a promise with a callback in <code>then</code>. </p>
  
  <pre><code>router.get('/register', (req, res) =&gt; {
      res.redirect('/')           
      doSomethingAsync().then(() =&gt; {
          console.log(1)
      })
  }
  
  router.get('/', (req, res) =&gt; {
     console.log(2)
     ...
  }
  </code></pre>
  
  <p>This would print out <code>2</code>, then <code>1</code>, meaning that we can exit immediately and redirect the user.
  Isn't the second way better for performance? Or are they actually the same?</p>