2021年4月9日星期五

What is the best way to resolve deadlock in httpwebrequest?

Recently my server CPU usage is reaching 100% due to unknown reason.

After analyzing the dump file, I found out it could be a deadlock issue in my code.

From the dump file I got following information:

This thread is making an HttpWebRequest and waiting on the remote server to respond  HttpRequest URI:https://xxx.azurewebsites.net/api/  ServicePoint - ConnectionLimit:2147483647 CurrentConnections:1  

I have a task where it makes a http request to the third party API whenever a transaction is created. I am using following method to call the request. This task usually process 4-5 requests in a minute during peak hours.

 protected virtual WebResponse GetWebResponse(WebRequest request)      {        WebResponse response = request.GetResponse();        this.m_WebResponse = response;        return response;      }  

Can somebody explain how could a deadlock happens in such way. Why the server CPU usage is 100%.

https://stackoverflow.com/questions/67008065/what-is-the-best-way-to-resolve-deadlock-in-httpwebrequest April 09, 2021 at 12:20AM

没有评论:

发表评论