0

I have a WCF service, hosted on premisses, .Net Framework 3.5. Internally, in one operation that is exposes, it calls an external API that is hosted in Azure which returns a reply in JSON format.

This third party API is quite fast, usually it responds below 300ms, most of the times even below 100ms. The size of responses is less than 3KB.

What happens is that now & then I find that this WCF operation is quite slower than usual, and drilling down with some tooling (in this case, NewRelic), I find something like this:

STREAM/Get 11s

And it doesn't match with the times of API that is being called.

The piece of code that interacts with this API:

private List<Location> GetStuff()
    {
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://someendpoint");
        request.ContentType = "application/json";
        request.Headers["Authorization"] = "Bearer bla bla bla";

        using (var response = request.GetResponse())
        {
            NewtonsoftJsonSerializer serializer = new NewtonsoftJsonSerializer();
            
            // Deserialize response
            return serializer.Deserialize<List<Location>>(response.GetResponseStream());
        }        
    }

    public class Location
    {
        public string LocationId { get; set; }
        public int LocationTypeId { get; set; }
        public string Name { get; set; }
        public string Code { get; set; }
        public bool? Active { get; set; }
        public string DisplayName { get; set; }
        public List<Location> Children { get; set; }
    }

My question is: is the part of deserialization unefficient some how? Should I rewrite it in another manner? I'm not 100% sure, but this is the only culprit I find.

Other than this, could it be due to the fact that I'm calling an Azure API from an on premisses project?

Thank you

user729400
  • 495
  • 7
  • 18
  • Is the first call very slow, or is it always?https://stackoverflow.com/questions/10859832/why-is-the-first-wcf-client-call-slow and https://stackoverflow.com/questions/55580233/asp-net-webapi-performance-issues-slow-response – Lan Huang Jan 19 '22 at 08:36
  • Hi, it doesn't seem to be the first call – user729400 Mar 02 '22 at 10:59

0 Answers0