Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Does ManualResetEventSlim signaling degrades performance?

$
0
0

I am using ManualResetEventSlim to have signaling mechanism in my application and It works great if requests/sec are 100. As I increase request/sec, it gets worse.

Example:

100 Requests/sec -> 90% transaction done in 250 ms and Throughput (Success request/sec) is 134.

150 Requests/sec -> 90% transaction done in 34067 ms and Throughput (Success request/sec) is 2.2.

I use ConcurrentDictionary as give below:

// <key, (responseString,ManualResetEventSlim) >privatestaticConcurrentDictionary<string,(string,ManualResetEventSlim)>EventsDict=newConcurrentDictionary<string,(string,ManualResetEventSlim)>();

Below given process describes need for ManualResetEventSlim:

  1. Api Solution 1 (REST Api) received a request, it added an element (null, ManualResetEventSlim) in ConcurrentDictionary against a key and called thirdparty service (SOAP) using async/await. Thirdparty soap api returned acknowledgement response but actual response is pending. After getting acknowledgement response, it goes to ManualResetEventSlim.wait

  2. Once thirdparty processed the request, it calls Api Solution 2 (SOAP) using exposed method and sends actual response. Api solution 2 sends response to Api Solution 1 (REST Api) by making http request and then inserts data to database for auditlog.

  3. Api Solution 1 will get key from response string and update response string in ConcurrentDictionary and set signal.

  4. Api Solution 1 disposes ManualResetEventSlim object before returning response to client.


Viewing all articles
Browse latest Browse all 9386

Trending Articles