By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Problem: Huge overhead from making asynchronous SOAP calls...

P: n/a
In a newly created test app, to maximize client performance I tried to
make two SOAP method calls in tandem (the soap methods execute some
specified query), as each call includes a large amount of idle time by
the client as it waits for a query to execute and return a dataset.

As a test, I initially wrote two versions:
' // Sequential & Synchronous
Dim webobj As com.mycompany.webobject
Dim ds1 As System.Data.DataSet
Dim ds2 As System.Data.DataSet
webobj = new com.mycompany.webobject
ds1 = webobj.Test("qry_1")
ds2 = webobj.Test("qry_2")
MsgBox "Done!"
' // Asynchronous
Dim webobj As com.mycompany.webobject
Dim arQry1 As IAsyncResult
Dim arQry2 As IAsyncResult
Dim ds1 As System.Data.DataSet
Dim ds2 As System.Data.DataSet
webobj = new com.mycompany.webobject
arQry1 = webobj.BeginTest("qry_1", Nothing, Nothing)
arQry2 = webobj.BeginTest("qry_2", Nothing, Nothing)
ds1 = webobj.EndTest(arQry1)
ds2 = webobj.EndTest(arQry1)
MsgBox "Done!"

.....

Query 1 returns about 18,000 rows while Query 2 returned about 200.
The surprising result was that the asynchronous way took about 30
seconds while the synchronous way took about 13.

As a reality check, I then changed Query 2 to a longer running query
which returned about 10,000 rows. I also created a third,
multi-threaded version of the test. Each thread calls the SYNCHRONOUS
SOAP method and for the most part, it should be approximately the same
as the asynchronous version.

As expected, the multi-threaded version outperforms the sequential
version. But even with TWO long-running queries, the asynchronous
version STILL underperforms the sequential version!
Someone suggested updating the file machine.config with
maxconnections="10" (from "2") but this had no effect in my cas.

Any ideas as to what's going on? I have no problems creating a
multi-threaded application if that's what it takes, but for
maintainability I'd rather keep the code as simple as possible if I
can.

Thanks!

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

A synchronous doesnt let anything else run until that call is done.
An asynchronous call runs in the background so it takes longer. The biggest
advantage of asynchronous call is that the function call will not lock up
the computer and make it seam unresponsive.

Ken
------------
<us***********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
In a newly created test app, to maximize client performance I tried to
make two SOAP method calls in tandem (the soap methods execute some
specified query), as each call includes a large amount of idle time by
the client as it waits for a query to execute and return a dataset.

As a test, I initially wrote two versions:
' // Sequential & Synchronous
Dim webobj As com.mycompany.webobject
Dim ds1 As System.Data.DataSet
Dim ds2 As System.Data.DataSet
webobj = new com.mycompany.webobject
ds1 = webobj.Test("qry_1")
ds2 = webobj.Test("qry_2")
MsgBox "Done!"
' // Asynchronous
Dim webobj As com.mycompany.webobject
Dim arQry1 As IAsyncResult
Dim arQry2 As IAsyncResult
Dim ds1 As System.Data.DataSet
Dim ds2 As System.Data.DataSet
webobj = new com.mycompany.webobject
arQry1 = webobj.BeginTest("qry_1", Nothing, Nothing)
arQry2 = webobj.BeginTest("qry_2", Nothing, Nothing)
ds1 = webobj.EndTest(arQry1)
ds2 = webobj.EndTest(arQry1)
MsgBox "Done!"

.....

Query 1 returns about 18,000 rows while Query 2 returned about 200.
The surprising result was that the asynchronous way took about 30
seconds while the synchronous way took about 13.

As a reality check, I then changed Query 2 to a longer running query
which returned about 10,000 rows. I also created a third,
multi-threaded version of the test. Each thread calls the SYNCHRONOUS
SOAP method and for the most part, it should be approximately the same
as the asynchronous version.

As expected, the multi-threaded version outperforms the sequential
version. But even with TWO long-running queries, the asynchronous
version STILL underperforms the sequential version!
Someone suggested updating the file machine.config with
maxconnections="10" (from "2") but this had no effect in my cas.

Any ideas as to what's going on? I have no problems creating a
multi-threaded application if that's what it takes, but for
maintainability I'd rather keep the code as simple as possible if I
can.

Thanks!
Nov 21 '05 #2

P: n/a
I would whole-heartedly agree, except for the following:
- Most of the processing time is on the back-end server, which is IIS
(for the SOAP call) and SQL Server (for the database query).
- I created a third, multi-threaded version which makes two SOAP calls
at once; neither SOAP calls are on the main thread, which means both
threads are effectively in the background.

However, in my multi-threaded version I put the main thread to sleep
for 0.3 seconds between checks. To see what I mean...

' // WebObjWrapper wraps the SOAP object
com.mycompany.webobject
' // and adds covenience functions for threading.
Dim qry1 As com.mycompany.WebObjWrapper
Dim qry2 As com.mycompany.WebObjWrapper
Dim thrd1 As System.Threading.Thread
Dim thrd2 As System.Threading.Thread
Dim time1 As System.DateTime
Dim time2 As System.DateTime

qry1 = New com.mycompany.WebObjWrapper("qry_1")
qry2 = New com.mycompany.WebObjWrapper("qry_2")

thrd1 = New Thread(AddressOf qry1.ThreadProc)
thrd2 = New Thread(AddressOf qry2.ThreadProc)

thrd1.Start()
thrd2.Start()

While (Not qry1.IsFinished Or Not qry2.IsFinished)
Thread.Sleep(300)
End While

ds1 = qry1.DataSet
ds2 = qry2.DataSet
MsgBox("Done")
Perhaps it's possible that in the asynchronous version, the main thread
is soaking up a lot more processing power?

Nov 21 '05 #3

P: n/a
FYI for anyone that's curious:
http://msdn.microsoft.com/library/de...netchapt10.asp
Note You should not use asynchronous Web methods when accessing a

database. ADO.NET does not provide asynchronous implementation for
handling database calls. Wrapping the operation in a delegate is not an
option either because you still block a worker thread.

I'm not sure what's the difference internally (client OR server)
between making a synchronous and asynchronous call, but apparently
ADO.NET isn't happy with asynchronous calls.

Thanks.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.