For Programmers: Free Programming Magazines  


Home > Archive > Microsoft Webservices > May 2005 > ASP.Net Web Service Performance Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ASP.Net Web Service Performance Question
GCeaser@aol.com

2005-05-05, 4:02 pm

All,

I am in the process of setting up some standards for how Web
Services should be implemented at our shop. To that end I have done
some performance testing of various options for passing information in
and out of web services including


For single records of information I have tested:
1. Using input / output parameters - Example:
public void GetInformation(ref string ps_Description, ref string
user_name)

2. Using custom objects - Example:
public MyCustomObject GetInformation()

For multiple records of information I have tested:

1. Using a dataset as the return object (also tested strongly typed
datasets) - Example:
public DataSet GetInformation()
Or
public StrongTypedDataSet GetInformation()

2. Using custom objects - Example:
public MyCustomObject GetInformation()


For a single record there is almost no difference between the
performance of the two and in actuality, more often than not, the
custom object comes back a few milliseconds faster.

For multiple records, the same is true in that the custom objects
perform better, usually returning data .1 to .2 seconds faster. This
is the case even with all the extra of custom objects. For example I
have added code to make the custom objects more usable by allowing
ArrayLists to be the return object type and adding a call to a custom
class on the client side that will convert all the object variables
back into properties so the object can be bound to an object on the
client.

I guess I am a little confuse because this data seems to support a
theory that developer custom objects are more efficient when it comes
to web service performance than objects built into .Net by Microsoft
(IE DataSets and variables as parameters). I do realize that a dataset
has extra overhead associated with it. However, I would think the
custom code needed to open a datareader, return all the data one record
at a time and load it into a custom object, then rebuild that object on
the client while converting all the variables back to properties for
use in binding would perform at least slightly worse than using the
Microsoft objects.

Am I missing something here?
Thanks
George

Kevin Spencer

2005-05-05, 4:02 pm

Hi George,

> I do realize that a dataset
> has extra overhead associated with it. However, I would think the
> custom code needed to open a datareader, return all the data one record
> at a time and load it into a custom object, then rebuild that object on
> the client while converting all the variables back to properties for
> use in binding would perform at least slightly worse than using the
> Microsoft objects.


You're only missing one thing: A DataSet is created by using a DataReader
internally, and all of the stuff that you mentioned is done in creating the
DataSet. In addition, the DataSet has extra functionality that you may not
need for your Web Service. A DataSet is actually a container for DataTables.
So, if you're only returning one Record Set, the container isn't necessary.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You S Is What You Get.

<GCeaser@aol.com> wrote in message
news:1115298833.292734.285180@f14g2000cwb.googlegroups.com...
> All,
>
> I am in the process of setting up some standards for how Web
> Services should be implemented at our shop. To that end I have done
> some performance testing of various options for passing information in
> and out of web services including
>
>
> For single records of information I have tested:
> 1. Using input / output parameters - Example:
> public void GetInformation(ref string ps_Description, ref string
> user_name)
>
> 2. Using custom objects - Example:
> public MyCustomObject GetInformation()
>
> For multiple records of information I have tested:
>
> 1. Using a dataset as the return object (also tested strongly typed
> datasets) - Example:
> public DataSet GetInformation()
> Or
> public StrongTypedDataSet GetInformation()
>
> 2. Using custom objects - Example:
> public MyCustomObject GetInformation()
>
>
> For a single record there is almost no difference between the
> performance of the two and in actuality, more often than not, the
> custom object comes back a few milliseconds faster.
>
> For multiple records, the same is true in that the custom objects
> perform better, usually returning data .1 to .2 seconds faster. This
> is the case even with all the extra of custom objects. For example I
> have added code to make the custom objects more usable by allowing
> ArrayLists to be the return object type and adding a call to a custom
> class on the client side that will convert all the object variables
> back into properties so the object can be bound to an object on the
> client.
>
> I guess I am a little confuse because this data seems to support a
> theory that developer custom objects are more efficient when it comes
> to web service performance than objects built into .Net by Microsoft
> (IE DataSets and variables as parameters). I do realize that a dataset
> has extra overhead associated with it. However, I would think the
> custom code needed to open a datareader, return all the data one record
> at a time and load it into a custom object, then rebuild that object on
> the client while converting all the variables back to properties for
> use in binding would perform at least slightly worse than using the
> Microsoft objects.
>
> Am I missing something here?
> Thanks
> George
>



GCeaser@aol.com

2005-05-05, 9:00 pm

Kevin,

Thanks for the reply. I get that a Dataset is using a Datareader
under the covers. Thus my thinking that it is very akin to creating a
custom object and loading it from a datareader. My thought was that
the performance of the MS objects would be faster than performing that
task myself.

With regard to the DataTable versus DataSet. Good Point. Are
DataTables directly serializable as DataSets are? Also, is it possible
to define a strongly typed DataTable and just pass that back from a Web
Service so the users would get intelisence etc?

Any information would be appreciated.

Kevin Spencer

2005-05-06, 4:02 pm

Hi GC,

> My thought was that
> the performance of the MS objects would be faster than performing that
> task myself.


That all depends on your skill level. Remember that the MS objects were
created just as you do, by employing the CLR, by programmers like yourself
and myself. The DataSet is a one-size-fits-all type of class designed for
speed of development on the part of those who have time pressure on them,
and for those who have the time but are too ignorant to develop their own
classes (unfortunately, there are many such "programmers " out there).

> With regard to the DataTable versus DataSet. Good Point. Are
> DataTables directly serializable as DataSets are? Also, is it possible
> to define a strongly typed DataTable and just pass that back from a Web
> Service so the users would get intelisence etc?


The DataTable class is marked as serializable, and according to the .Net
SDK, "The DataSet and DataTable objects inherit from
MarshalByValueComponent, and support the ISerializable interface for
remoting. These are the only ADO.NET objects that can be remoted."

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You S Is What You Get.

<GCeaser@aol.com> wrote in message
news:1115326339.156092.146080@z14g2000cwz.googlegroups.com...
> Kevin,
>
> Thanks for the reply. I get that a Dataset is using a Datareader
> under the covers. Thus my thinking that it is very akin to creating a
> custom object and loading it from a datareader. My thought was that
> the performance of the MS objects would be faster than performing that
> task myself.
>
> With regard to the DataTable versus DataSet. Good Point. Are
> DataTables directly serializable as DataSets are? Also, is it possible
> to define a strongly typed DataTable and just pass that back from a Web
> Service so the users would get intelisence etc?
>
> Any information would be appreciated.
>



GCeaser@aol.com

2005-05-06, 4:02 pm


Kevin,

So it turns out DataTables are NOT serializable for Web Services as
documented below:

'.. because DataSets handle the serialization of DataTables for
marshaling purposes, you can't pass individual DataTables either.'

So I guess we are stuck with the dataset of creating a custom object.
I really wish Microsoft would make a trimmed down, efficient (IE
performs better than a custom object) data object to return multiple
rows of data via a web service. Oh well.. until then, looks like
custom objects are the most effective way to go from a performance
standpoint.

Thanks
GC

Kevin Spencer

2005-05-06, 4:02 pm

Or you could create your own serializable "DataTable-like" class.

I do seem to recalll this, now that you mention it. And I was as
disappointed as you are.

One thing you CAN do: Structures are primitive data types, and as such are
serializable. Arrays of primitives are also serializable. So, you could
emulate a DataTable with an array of structures. Each struct would represent
a row in the "table."

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You S Is What You Get.

<GCeaser@aol.com> wrote in message
news:1115398849.071953.153410@f14g2000cwb.googlegroups.com...
>
> Kevin,
>
> So it turns out DataTables are NOT serializable for Web Services as
> documented below:
>
> '.. because DataSets handle the serialization of DataTables for
> marshaling purposes, you can't pass individual DataTables either.'
>
> So I guess we are stuck with the dataset of creating a custom object.
> I really wish Microsoft would make a trimmed down, efficient (IE
> performs better than a custom object) data object to return multiple
> rows of data via a web service. Oh well.. until then, looks like
> custom objects are the most effective way to go from a performance
> standpoint.
>
> Thanks
> GC
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com