The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by bmeyvin]

Dear Fergal,

Thank you for the excellent book! It was a joy to read a book that makes sense.

I am evaluating viability of the .Net framework for enterprise-class
applications. One of the critical requirements is high efficiency of DAO tier.

I inserted few timestamps in pubscount.cs (chapter 4) as follows:

public static void Main() {

DateTime StartTime = DateTime.Now;

// change the following connection string, as necessary...
string con =
//@"server=(local)NetSDK;database=pubs;trusted_connection=yes";

@"server=192.168.123.101;database=pubs;trusted_connection=yes";
DataSet ds = new DataSet("PubsDataSet");
SqlDataAdapter sda;
string sql;

DateTime Time_1 = DateTime.Now;
sql = "SELECT COUNT(*) AS cnt FROM authors";
DateTime Time_2 = DateTime.Now;
sda = new SqlDataAdapter(sql, con);
DateTime Time_3 = DateTime.Now;
sda.Fill(ds, "a_count");
DateTime Time_4 = DateTime.Now;
...


...and got the following trace:

******************************************************
C:BooksDotNetcha_4>csc pubscount.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.


C:BooksDotNetcha_4>pubscount
There are 23 authors, 18 titles and 8 publishers.
Start time is 1:01:54 PM
...1 time is 1:01:54 PM
...2 time is 1:01:54 PM
...3 time is 1:01:54 PM
...4 time is 1:02:29 PM
...5 time is 1:02:29 PM
...6 time is 1:02:29 PM
...7 time is 1:02:29 PM
End time is 1:02:29 PM

C:BooksDotNetcha_4>

It took 35 seconds to execute sda.Fill(ds, "a_count");

Here is some setup info:
C# executable runs on 600MHz, 256 MB laptop and goes against SQL2000 server
that is hosted on 1.2GHz, 512 MB laptop. Machines are on a LAN.

Am I missing some vital config. optimizations required for .Net applications?
Can anybody point me to good scalability studies on ADO.NET and/or share
hands-on experience on this subject? Anything that benchmarks .Net against
J2EE and/or Windows DNA?

Thanks!
Ben
import-bot (20211) [Avatar] Offline
#2
Re: ADO.NET DataSet
[Originally posted by fgrimes]

Hi Ben,

>> Thank you for the excellent book!
>> It was a joy to read a book that makes sense.

I'm glad you enjoyed it.

>> It took 35 seconds to execute sda.Fill(ds, "a_count"smilie;

I just tried it on my 900Mhz, 512MB laptop and it took less than one second.
(Client and server both on laptop.) However such tests are notoriously
unreliable since there are so many external factors at work.

>> Can anybody point me to good scalability studies on
>> ADO.NET and/or share hands-on experience on this subject?

Anyone out there who can answer this?

>> Anything that benchmarks .Net against J2EE ...

Reported .NET/J2EE comparisons will likely be ruined by partisanship. For
example, you can start with the J2EE/.NET "Pet Store" debate. Read
Microsoft's side of the argument at
http://gotdotnet.com/team/compare/petshopfaq.aspx. You'll find the J2EE case
("The Case of the Bogus Benchmarks") at
http://www.oracle.com/features/oow/index.html?oow01_msbench.html.

Regards,
Fergal
import-bot (20211) [Avatar] Offline
#3
Re: ADO.NET DataSet
[Originally posted by bmeyvin]

Intriguing… I have installed SQL on my client PC to reproduce your test. I
also got less then 1 sec. However, when I go across the LAN I consistently get
~35 sec. I made sure that machines are not running anything that can
conceivably interfere with the test. I am pretty sure that LAN bandwidth is
not a culprit here. It takes ~4 sec to move a 3 MB file from server to client
machine (pubs database is a little bit over 2 MB) I will let you know if I
find the root cause of such a high latency.

Thank you for links on J2EE vs. .Net comparison. I am coming from J2EE
background and know how heated such a debate can be. The fact of the matter is
that both platforms will have to co-exist for some time. Books like yours are
a real help. I will make sure to post to amazon.com

Thanks again.

Ben
import-bot (20211) [Avatar] Offline
#4
Re: ADO.NET DataSet
[Originally posted by ekinated]

Ben,

Is this something that’s limited to .NET or is the issue somewhere else? Try
this little VBScript sample using both the local db and the remote db and see
what it returns:

‘---------------------------------------------------------------------------------


Option Explicit

Const DEFAULT_DB_SERVER = "(local)"

Dim dbServer
dbServer = InputBox("Enter the db server name", "Benchmark connection
execution", DEFAULT_DB_SERVER)

Dim connection
Set connection = CreateObject("ADODB.Connection")

connection.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial
Catalog=pubs;Data Source=" & dbServer

Dim startedAt
startedAt = Time()

Dim recordset
Set recordset = connection.Execute("SELECT COUNT(*) AS cnt FROM authors")

Dim count
count = recordset("cnt").Value

MsgBox "Duration = " & DateDiff("s", startedAt, Time()) & " seconds"

‘---------------------------------------------------------------------------------


Also, do you see this delay every time you execute a command to the remote db
or just the first time a command is executed in your program? I’m also
curious what timings you’d see if you used standard security (user
id=sa;password=secretsmilie instead of integrated security.

I ran your code sample and I got less than .5 seconds when the local machine
was the db server, and about 1.5 seconds when the db server was on a remote
machine (on the same subnet). What does your network setup look like? For my
tests, I used a simple 5 port switch (I’m at home right now) where there was
little or no other traffic.

In general, here are some articles that you may find helpful on data access
benchmarks using ADO.NET:

Performance Comparison: Data Access Techniques
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/bdadotnetarch031.asp


MSDN .NET Architecture Center Home
http://msdn.microsoft.com/architecture/EACtrAppDev.asp

Best Practices for Using ADO.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/adonetbest.asp

import-bot (20211) [Avatar] Offline
#5
Re: ADO.NET DataSet
[Originally posted by bmeyvin]

Eric, thank you for the hint. Latency is related to integrated security.

With //@"server=192.168.123.101;database=pubs;trusted_connection=yes";

it takes 35 seconds to execute sda.Fill(ds, "a_count") against remote SQL
server.

With @"server=192.168.123.101;database=pubs;uid=sa;pwd=";

the same takes less then 1 sec.

My remote SQL server is configured for SQL authentication.

Regards,
Ben