Exceptions should be hardly used in exception : Inner Voice #Microsoft #Core #Pipeline

Exceptions and Performance Concerns for ASP.Net Microsoft Team

Exceptions are fully asynchronous and nested but extremely expensive, even more expensive than usual when they are in the ASP.Net Core Pipelines.


Microsoft Performance Team had raised this concern for high scale services long back,

To improve performances sharing couple of key points when developing with .net core

  • Async Void Methods: Using async void in ASP.NET Core is considered a bad practice because unhandled exceptions thrown from these methods will crash the entire process. It is recommended to use Task-returning methods instead. HttpContext Usage: Accessing HttpContext from multiple threads in parallel, storing it in a field, or using it after the request is complete can lead to NullReferenceException or other issues because it is not thread-safe and is disposed after the request pipeline ends.
  • Exception Handling Middleware: The built-in UseExceptionHandler middleware is designed to catch exceptions early in the pipeline. It cannot handle exceptions if the response has already started (e.g., headers sent), as it can't modify the response mid-stream.
  • Developer Exception Page: This feature provides detailed information about unhandled exceptions during the development environment and has seen improvements over time in terms of usability and clarity.
  • Problem Details (RFC 7807/9457): For API error handling, discussions have involved standardizing error responses using "Problem Details" to provide machine-readable error details in HTTP responses, often utilizing a third-party package like Hellang.Middleware.ProblemDetails or built-in features.
  • Troubleshooting & Diagnostics: For web applications, We can use performance tools such as httparchive(har) to understand root cause.

Comments

Popular posts from this blog

Ohh It is digital transformation, .. Really ?

Respect is not earned, It is given ⚘ 🙏

Need > Want

Popular posts from this blog

Typical Project flow with QA Loop in Jira (Atlassian)

Increase ROI in your organization with Automation Testing

Tip to create workflow in JIRA quickly

Headless Automation Testing

QuickTest Pro and Traceability Matrix

Ohh It is digital transformation, .. Really ?

AFT (Automation Framework Team) should not take developers' false catches