| < Day Day Up > |
18.6. Web Services Performance
The performance of a Web Service from both the client and server side is affected by a variety of factors. Some are .NET
Configuring the HTTP Connection
Connections (HTTP) to Internet resources are managed in .NET by the
ServicePoint
class. This class includes properties to specify a connection's timeout interval, set its security protocol, and manage the use of server security certificates. It also includes properties that directly affect how much delay is incurred before a Web Service request is transmitted over a network:
UseNagleAlgorithm
and
Expect100Continue
. Despite the
Expect100Continue
This property determines whether a
POST
request should expect to receive a 100-Continue response from the server to
Because Web Service calls tend to pass small amounts of data, it can be beneficial to
The Nagle AlgorithmOne way to improve network efficiency is to reduce the number of small data packets sent across a network. To accomplish this, the software layer controlling the underlying TCP (Transmission Control Protocol) connection attempts to accumulate, or buffer, small messages into a larger TCP segment before they are sent. The technique to do this is based on the Nagle algorithm . [4]
The crux of the algorithm is that small amounts of data should continue to be collected by TCP until it receives acknowledgment to send the data. .NET institutes a delay of up to 200 milliseconds to collect additional data for a packet. For a typically small Web Service request, there may be no reason to include this delay. It's an option you can experiment with. To set the Expect100Continue and UseNagleAlgorithm properties, it is necessary to get a reference to the ServicePoint object being used to handle the Web request. This is done in the proxy code on the client side. Refer to Listing 18-2, and you'll see that the proxy code consists of a class derived from the base SoapHttpClientProtocol class. By overriding the inherited GetWebRequest method, you can customize the WebRequest object before the request is sent to the Web Service. Add the following code to override the GetWebRequest method. Inside the method, you use the Uri object to get the ServicePoint . Its properties can then be turned off or on to test performance:
// Using System.Net must be added
protected override WebRequest GetWebRequest(Uri uri)
{
// Locate ServicePoint object used by this application
ServicePoint sp =
ServicePointManager.FindServicePoint(uri);
sp.Expect100Continue = false;
sp.UseNagleAlgorithm = false;
return WebRequest.Create(uri);
}
Working with Large Amounts of Data
Although the XML format offers a great deal of flexibility in representing data, it can place a
For large amounts of data, consider these options:
|
| < Day Day Up > |