5

I'm using SimpleDB in a desktop application (C#, .NET 2.0) and have a problem with high latency.
The first time I make a request to the DB (query, insert values - doesn't matter) I get a response only after about 10-20 seconds. This happens only the first time, the rest of the responses are pretty fast (haven't measured, but under 300ms for sure).
This doesn't happen when I create the DB client, only when I do the first request. Is it normal for authentication to be that slow? (I presume that on the first request authentication is done).

Thanks in advance.

EDIT

When I run the first time something like

SelectResponse response = dbService_.Select(request);

in the output panel I get:

'PhotoExchange.vshost.exe' (Managed (v2.0.50727)): Loaded'C:\Windows\assembly\GAC_MSIL\System.Data.SqlXml\2.0.0.0__b77a5c561934e089\System.Data.SqlXml.dll'
'PhotoExchange.vshost.exe' (Managed (v2.0.50727)): Loaded 'System.Xml.Xsl.CompiledQuery.1'
'PhotoExchange.vshost.exe' (Managed (v2.0.50727)): Loaded 'System.Xml.Xsl.CompiledQuery'
 A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
'PhotoExchange.vshost.exe' (Managed (v2.0.50727)): Loaded 'rg1d4wjc'  

Is it normal? The FileNotFoundException looks very strange.

Gratian Lup
  • 1,485
  • 3
  • 19
  • 29
  • Authentication happens on every request. – Rex M Feb 17 '11 at 18:35
  • You're right, it's probably based on REST. Then why is it so slow only on the first request? I really can't understand. – Gratian Lup Feb 17 '11 at 18:38
  • @Rangoric: I'm not sure what you mean... How much time passes between tests involving the DB? – Gratian Lup Feb 17 '11 at 18:55
  • You can flag to break on all exceptions (Ctrl+Alt+E) so you can see where the FileNotFound exception is coming from. It may be inside the framework, though, so you may need to enable stepping into that. What's the last one, BTW - what's it being generated from? Does that take the 10-15 secs to appear if you watch the output window? – Rup Feb 17 '11 at 19:33
  • 3
    @Rup: It seems that it's trying to find a precompiled DLL that could speed up XML serialization. The exception is the mechanism used to check if this DLL is available. If it's not it creates one then. It searches for "AWSSDK.XmlSerializers.DLL", but strange is that it also doesn't create it. – Gratian Lup Feb 17 '11 at 20:15

5 Answers5

4

Sounds like something is timing out, then silently failing over to a successful second channel that is then cached for subsequent calls. First suspicion? DNS, probably. I'd check your workstation's TCP/IP settings to see if your Primary DNS server is up, or replace them with Google's Public DNS at 8.8.8.8 and 8.8.4.4

Chris Wenham
  • 23,679
  • 13
  • 59
  • 69
1

It may be WebProxy detection (I assume the .NET client you are using is just a wrapper around a web service).

See if you can disable/null out the WebProxy property on the WebClient being used by the service wrapper.

Andrew
  • 1,606
  • 1
  • 12
  • 19
0

At a guess, you're building the service client dynamically from the WSDL at runtime - although I'm not sure it should take that long.

Instead you could build this into your project in advance by adding a web service reference in Visual Studio or using svcutil.exe (the equivalent command-line utility).

Rup
  • 33,765
  • 9
  • 83
  • 112
  • I added a web reference to "http://sdb.amazonaws.com/doc/2009-04-15/AmazonSimpleDB.wsdl" and it's still the same. – Gratian Lup Feb 17 '11 at 18:53
0

.NET does Just in time (JIT) compilation (compiles the code when it is first run), theres always a speed penalty on the first iteration (altough 10-20 seconds seems huge).

I have never used them but there are tools like ngen which allows you to compile the code beforehand.

In applications where I cant allow the first iteration to be slow I usually initialize the application by having "dummy" data run through my critical path.

There are probably other causes for the problem, but I would investigate that.

Hopefully that helps

Benoittr
  • 4,091
  • 4
  • 27
  • 38
0

Probably there is something wrong with my Windows/.NET installation. I took a sample from the SDK, compiled it (even used NGEN) and got about 30 sec delay on the first request. I copied the same executable to a virtual machine and the delay was 5 seconds. Still pretty big, but it's acceptable.

Gratian Lup
  • 1,485
  • 3
  • 19
  • 29