Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP Request performance for large volumes of requests
    text
    copied!<p>I'm looking for some advice on how to optimise the following process:</p> <p>App reads csv file. For each line in the file an XML message is created Each XML message is posted to a URL via a HTTPWebRequest</p> <p>This process was designed to handle low volumes of messages (up to about 200 at a time), un suprisingly thinks have changed and it is now expected to handle up to about 3000 at a time.</p> <p>The code used to post the message is here:</p> <pre><code>Public Function PostXml(ByVal XML As String) As HttpStatusCode Try Dim Bytes As Byte() = Me.Encoding.GetBytes(XML) Dim HTTPRequest As HttpWebRequest = DirectCast(WebRequest.Create(Me.PostURL), HttpWebRequest) With HTTPRequest .Method = "POST" .ContentLength = Bytes.Length .ContentType = "text/xml" .Credentials = New NetworkCredential(_Settings.NTSPostUsernameCurrent, _Settings.NTSPostPasswordCurrent) End With Using RequestStream As Stream = HTTPRequest.GetRequestStream() RequestStream.Write(Bytes, 0, Bytes.Length) RequestStream.Close() End Using Using Response As HttpWebResponse = DirectCast(HTTPRequest.GetResponse(), HttpWebResponse) Return Response.StatusCode End Using Catch ex As WebException If ex.Message.Contains("(500) Internal Server Error") Then Return HttpStatusCode.InternalServerError Else Throw End If End Try </code></pre> <p>Can this be optimised in terms of caching the connection used? At the moment there is a noticable delay at the line: <code>Using Response As HttpWebResponse</code> while the connection is made. Is there a way of caching this so the same connection is used for all 3000 messages rather than a new connection being created for each message? </p> <p>Any advice gratefully recieved.</p> <p>**Update. Thanks for the responses. To clarify, I am currently restricted to sending multiple messages due to restrictions elsewhere in the system. There is a noticable delay in responding to the request at the other end (the receiver) but this is outside my control. I am trying to ensure that the process of sending is as efficient as possible (external factors notwithstanding).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload