Developing Microsoft Azure and Web Services — Question 83
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?
Answer options
- A. Implement a Using statement block when declaring the HttpClient object.
- B. Increase the value of the Timeout property when declaring the HttpClient object.
- C. Use the static modifier to declare the HttpClient object.
- D. Create a new HttpClient instance for each API request and use asynchronous method calls.
Correct answer: C
Explanation
The correct answer is C because using a static HttpClient instance allows for better resource management and avoids socket exhaustion during high traffic. Options A and B do not address the underlying issue of socket management, while option D can lead to performance degradation due to the overhead of creating multiple instances.