The performance of ServiceClient #346
Replies: 7 comments 12 replies
-
I compared the performance |
Beta Was this translation helpful? Give feedback.
-
Were you running the ServiceClient as .net 4.8 previously? or were you using CrmServiceClient? second, if you're working against a single endpoint and are trying to manage horizontal scale out ('n' threads), you need to be sensitive to the host platform which will tell you how many threads it will support. This is written for the CrmServiceClient and the WebAPI, however the concepts are identical for the ServiceClient (the updated article for ServiceClient is in process right now. ) |
Beta Was this translation helpful? Give feedback.
-
I suspect the issue your seeing is primarily due to the changes in .net 6, though I would need to see the failure messages your seeing to be sure. What your using there for setup works well for ServiceClient ( though I would make sure your on the latest version of the service client ). Depending on your hosting Infra, ( functions / API service / WebSite/ etc.. ) One thing to make sure of though is that your are managing token cache in your auth behavior so that you do not ask for tokens unless you need to. |
Beta Was this translation helpful? Give feedback.
-
Morning @MattB-msft |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hi Matt, I have created testing solution |
Beta Was this translation helpful? Give feedback.
-
@heroes3lover I apparently missed this post, Can you reissue that invite please? |
Beta Was this translation helpful? Give feedback.
-
Hello experts,
I am trying to find a solution for timeout issues.
After moving web app from .net framework 4.6.2 to .net 6,
Except upgrade a few deprecated packages and replace crmsdk with Power Platform dataverse client, most of code are same.
Now noticed lots of timeout issues with serviceclient, every morning when massive requests come in I saw 2k, 3k 500 errors, and from Azure portal failed request logs are all showing "fail connection to dataverse" some even in 16 ms.
Then I tested in local machine,
I wrote another test console to send same get request to web api which just queries one entity record from D365 and return.
if ServiceClient registered as scope and implemented with clone method it can handle 10 tasks running in parallel.
If ServiceClient registered as singleton it can handle 100 tasks in parallel.
If 1000 tasks run in parallel, all of them failed with timeout error errors, but when I tested with crmsdk package, it can succeed around 270 requests. fail 730 requests.
Is there anyone was facing same issue before?
testing code is simple:
using MultipleApiCall;
using Newtonsoft.Json;
using System.Net.Http.Headers;
var count = 1000;
async Task GetCustomer(string url, HttpClient client)
{
try
{
//GET Method
using (var response = await client.GetAsync(url))
{
return (int)response.StatusCode;
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return 0;
}
}
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
Beta Was this translation helpful? Give feedback.
All reactions