Valid 70-487 Dumps shared by ExamDiscuss.com for Helping Passing 70-487 Exam! ExamDiscuss.com now offer the newest 70-487 exam dumps, the ExamDiscuss.com 70-487 exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com 70-487 dumps with Test Engine here:
You deploy a RESTful ASP.NET Web API to manage order processing. You are developing an Azure App Services Web App to consume the API and allow customers to order products. You use the HttpClient object to process order entries. The API throws SocketException errors when the Web App experiences a high volume of concurrent users. You need to resolve the errors. What should you do?
Correct Answer: C
Explanation/Reference: Explanation: If the class that wraps the external resource is shareable and thread-safe, create a shared singleton instance or a pool of reusable instances of the class. The following example uses a static HttpClient instance, thus sharing the connection across all requests. public class SingleHttpClientInstanceController : ApiController { private static readonly HttpClient httpClient; static SingleHttpClientInstanceController() { httpClient = new HttpClient(); } // This method uses the shared instance of HttpClient for every call to GetProductAsync. public async Task<Product> GetProductAsync(string id) { var hostName = HttpContext.Current.Request.Url.Host; var result = await httpClient.GetStringAsync(string.Format("http://{0}:8080/api/...", hostName)); return new Product { Name = result }; } } References: https://docs.microsoft.com/en-us/azure/architecture/antipatterns/improper-instantiation/