title: Conditions to use async-methods in c# .net-core web-apis
body: <p>I'm implementing several small services, each of which uses entity-framework to store certain (but little) data. They also have a fair bit of business-logic so it makes sense to separate them from one another.</p>
  <p>I'm certainly aware that async-methods and the async-await pattern itself can solve many problems in regards to performance especially when it comes to any I/O or cpu-intensive operations.</p>
  <p>I'm uncertain wether to use the async-methods of entity-framework logic (e.g. SaveChangesAsync or FirstOrDefaultAsync) because I can't find metrics that say &quot;now you do it, and now you don't&quot; besides from &quot;Is it I/O or CPU-Intensive or not?&quot;.</p>
  <p>What I've found when researching this topic (not limited to this but these are showing the problem):</p>
  <ul>
  <li><p>not using it can lead to your application stopping to respond because the threads (not the ones of the cpu, but virtual threads of the os) can run out because of the in that case blocking i/o calls to the database.</p>
  </li>
  <li><p>using it bloats your code and decreases performance because of the context-switches at every method. Especially when I apply those to entity-framework calls it means that I have at least three context switches for one call from controller to business-logic to the repository to the database.</p>
  </li>
  </ul>
  <p>What I don't know, and that's what I would like to know from you:</p>
  <ul>
  <li><p>How many virtual os threads are there? Or to be more precise: If I expect my application and server to be able to  handle 100 requests to this service within five seconds (and I don't expect them to be more, 100 is already exagerated), should I back away from using async/await there?</p>
  </li>
  <li><p>What are the precise metrics that I could look at to answer this question for any of my services?</p>
  </li>
  <li><p>Or should I rather always use async-methods for I/O calls because they are already there and it could always happen that the load-situation on my server changes and there's so much going on that the async-methods would help me a great deal with that?</p>
  </li>
  </ul>