.net core
performance
How can we increase the performance.
 Apply best practices.
 Memory and GC
 Response caching
 Response Compression
 Diagnostic tools
 Load/stress testing.
Best practices
1. Understand hot code paths.
2. Avoid blocking calls.
3. Minimize large object allocations.
4. Optimize data access and I/O.
5. Pool HTTP connections with HttpClientFactory.
6. Complete long-running Tasks outside of HTTP
requests.
7. Minify client assets.
8. Compress responses
9. Use the latest ASP.NET Core release.
10. Minimize exceptions.
11. Working with a synchronous data processing API
01) Understand hot code paths.
 Codes what frequency used.
 Add loggers to those codes and optimize specially it.
 Make clean middleware such as (logging,authorization ect)
 Beware when use customer middleware.
 Use performance profiling tools such as VS diagnostic tool
02) Avoid blocking calls.
ASP.NET Core apps should be designed to
process many requests simultaneously.
Asynchronous APIs allow a small pool of
threads to handle thousands of concurrent
requests by not waiting on blocking calls
02) Avoid blocking calls.
Dont Do
Don’t user Task.Wait,Task or Task.Result This will
be block tread synchronously
Make hot code paths asynchronous
Do not use Task.Run to make a synchronus API
asynchronous.
Make controller/Razor Page actions asynchronous
03) Minimize large object allocations.
4.Optimize data access and I/O.
(Database,File)
1. Do Async
2. Select only necessary data
3. Cache
4. Use Single call not several calls (select * from x ; select * from y)
5. User EF best practices.
5.Pool HTTP connections with
HttpClientFactory.
 Every http call open socket.
 When use httpClient socket are not reusable.and soket not immediately close even
http request over.and it has some cost when initialize a socket.
 Machine has limited number of socket can open. Therefor this will be make
performance issue.
 Therefor use HttpClientFactory.It will reuse previous socket asynchronously.
6. Complete long-running Tasks
outside of HTTP requests.
 User background process,SignalR.
7.Minify client assets.
 Minify or use cdn for js,css,html
8.Compress responses
 GZIP
 br (Brotli)
9.Use the latest ASP.NET Core
release.
10.Minimize exceptions.

Net core performance

  • 1.
  • 2.
    How can weincrease the performance.  Apply best practices.  Memory and GC  Response caching  Response Compression  Diagnostic tools  Load/stress testing.
  • 3.
    Best practices 1. Understandhot code paths. 2. Avoid blocking calls. 3. Minimize large object allocations. 4. Optimize data access and I/O. 5. Pool HTTP connections with HttpClientFactory. 6. Complete long-running Tasks outside of HTTP requests. 7. Minify client assets. 8. Compress responses 9. Use the latest ASP.NET Core release. 10. Minimize exceptions. 11. Working with a synchronous data processing API
  • 4.
    01) Understand hotcode paths.  Codes what frequency used.  Add loggers to those codes and optimize specially it.  Make clean middleware such as (logging,authorization ect)  Beware when use customer middleware.  Use performance profiling tools such as VS diagnostic tool
  • 5.
    02) Avoid blockingcalls. ASP.NET Core apps should be designed to process many requests simultaneously. Asynchronous APIs allow a small pool of threads to handle thousands of concurrent requests by not waiting on blocking calls
  • 6.
    02) Avoid blockingcalls. Dont Do Don’t user Task.Wait,Task or Task.Result This will be block tread synchronously Make hot code paths asynchronous Do not use Task.Run to make a synchronus API asynchronous. Make controller/Razor Page actions asynchronous
  • 7.
    03) Minimize largeobject allocations.
  • 8.
    4.Optimize data accessand I/O. (Database,File) 1. Do Async 2. Select only necessary data 3. Cache 4. Use Single call not several calls (select * from x ; select * from y) 5. User EF best practices.
  • 9.
    5.Pool HTTP connectionswith HttpClientFactory.  Every http call open socket.  When use httpClient socket are not reusable.and soket not immediately close even http request over.and it has some cost when initialize a socket.  Machine has limited number of socket can open. Therefor this will be make performance issue.  Therefor use HttpClientFactory.It will reuse previous socket asynchronously.
  • 10.
    6. Complete long-runningTasks outside of HTTP requests.  User background process,SignalR.
  • 11.
    7.Minify client assets. Minify or use cdn for js,css,html
  • 12.
  • 13.
    9.Use the latestASP.NET Core release.
  • 14.