title: IdentityServer4 with ASP.Net Core App : Performance issue - too slow
body: <p>I have an ASP.Net Core WebApp and a separate IdentityServer4 STS app with UI running on IIS. IS4 uses PostgreSQL.</p>
  
  <ul>
  <li>User clicks login </li>
  <li>App tries to load the default page (Loading.cshtml), IS4 checks user is unauthorized and redirects to IS4 login page</li>
  <li>User login via IS4 UI and gets redirected to ASP.Net Core App</li>
  </ul>
  
  <p>Issue is </p>
  
  <p>The first set of calls, checking unauthorized access and redirect to login page takes 8-9secs
  <a href="https://i.stack.imgur.com/N7ESq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N7ESq.png" alt="enter image description here"></a></p>
  
  <p>The second set of calls, after authentication, redirect to ASP.Net Core App takes 25-28secs</p>
  
  <p><a href="https://i.stack.imgur.com/hZL05.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hZL05.png" alt="enter image description here"></a>
  The app works fine in debugging mode, but I am seeing this performance issue when hosted in Azure.</p>
  
  <p>Technical info:</p>
  
  <ul>
  <li>Certificate (pfx file) is hosted in Azure with a 2048/sha256 encryption. Someone said the encryption part might be taking time so kept it at the lowest level.</li>
  <li>Caching has been enabled for all stores in IS4</li>
  </ul>
  
  <p>Not sure what I am missing, but this level of slow performance is unacceptable. Can you please help?</p>
  
  <p><strong>Update 1</strong>: Including Azure AppInsights data
  <a href="https://i.stack.imgur.com/aYEkk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aYEkk.png" alt="enter image description here"></a></p>
  
  <p><strong>Update 2 - Resolved</strong>: Found out what is causing the performance issue.</p>
  
  <p>I thought it was the Ids4 API calls that are causing the issue and hence upgraded the Azure AppService Plan and still did not see any difference. Later noticed there are close to 35+ scripts getting executed.</p>
  
  <p>So updated the Azure PostgreSQL plan from Basic to next tier - General Purpose and the performance increased drastically. The issue was with the Azure PostgreSQL through put.</p>
  
  <p>Here is the difference:
  <a href="https://i.stack.imgur.com/ZYAtk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZYAtk.png" alt="enter image description here"></a></p>