Web Services Processor Utilization

Discussion in 'ASP .Net Web Services' started by John Doe, Dec 17, 2005.

  1. John Doe

    John Doe Guest

    I have written a web service that returns an XmlDocument. The code is similar
    to the example below, except it returns an XmlDocument rather than an
    XmlDataDocument. When I run the service from the test harness in VS (or from
    a client page), CPU utilization on the Web server spikes to over 50% and
    returns quickly to around 0-5% after it has completed. I have tried the
    following:
    1) Changed the type returned by the web service to type string.
    2) Turned off Session State on the web server
    3) Turned off logging on the Web server
    4) Use anonymous authentication.

    I would like to limit the amount of processor used on the web server when
    the service is called. My client is concerned about this, because eventually
    there will be hundreds of concurrent users. What other steps can I take to
    limit the amount of CPU used?

    [WebMethod( Description="Returns Northwind Customers",EnableSession =false)]
    public XmlDocument GetData()
    {

    SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist
    Security Info=False;Initial Catalog=Northwind;Data Source=xxxxxxx");
    SqlDataAdapter cmd = new SqlDataAdapter("Select * from Customers",conn);
    DataSet ds = new DataSet();
    cmd.Fill(ds,"Orders");
    XmlDataDocument doc = new XmlDataDocument(ds);
    return doc;
     
    John Doe, Dec 17, 2005
    #1
    1. Advertising

  2. John Doe,

    > What other steps can I take to
    > limit the amount of CPU used?
    >
    > [WebMethod( Description="Returns Northwind Customers",EnableSession
    > =false)]
    > public XmlDocument GetData()
    > {
    >
    > SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist
    > Security Info=False;Initial Catalog=Northwind;Data Source=xxxxxxx");
    > SqlDataAdapter cmd = new SqlDataAdapter("Select * from Customers",conn);
    > DataSet ds = new DataSet();
    > cmd.Fill(ds,"Orders");
    > XmlDataDocument doc = new XmlDataDocument(ds);
    > return doc;


    Have you tried database connection pooling? Otherwise, you may want to time
    each statement in the web-service and determine what is causing the CPU
    load -- where is all the processing time spent.

    Regards,

    Randy
     
    Randy A. Ynchausti, Dec 17, 2005
    #2
    1. Advertising

  3. John Doe

    dbottjer Guest

    In the example you give your query users a "select *" I realize this is
    likely just an example but I would look at the query you are using and make
    sure you are returning only the data you need. For example, specify each
    collumn you need and do not use a select *. Furthermore, use a where clause
    to eliminate unwanted data.

    I would also suggest possibly applying indexes to the table or tables you
    are returning data from. Indexes can help the database find the results you
    are looking for faster.

    As previously suggested caching might be a good option to look at.

    Another suggestion would be to possibly look at using Data Transfermation
    Objects (DTO) instead of a data set. Datasets can get rather large and do
    have some overhead. Populating a collection of objects could possibly reduce
    some overhead.

    "John Doe" wrote:

    > I have written a web service that returns an XmlDocument. The code is similar
    > to the example below, except it returns an XmlDocument rather than an
    > XmlDataDocument. When I run the service from the test harness in VS (or from
    > a client page), CPU utilization on the Web server spikes to over 50% and
    > returns quickly to around 0-5% after it has completed. I have tried the
    > following:
    > 1) Changed the type returned by the web service to type string.
    > 2) Turned off Session State on the web server
    > 3) Turned off logging on the Web server
    > 4) Use anonymous authentication.
    >
    > I would like to limit the amount of processor used on the web server when
    > the service is called. My client is concerned about this, because eventually
    > there will be hundreds of concurrent users. What other steps can I take to
    > limit the amount of CPU used?
    >
    > [WebMethod( Description="Returns Northwind Customers",EnableSession =false)]
    > public XmlDocument GetData()
    > {
    >
    > SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist
    > Security Info=False;Initial Catalog=Northwind;Data Source=xxxxxxx");
    > SqlDataAdapter cmd = new SqlDataAdapter("Select * from Customers",conn);
    > DataSet ds = new DataSet();
    > cmd.Fill(ds,"Orders");
    > XmlDataDocument doc = new XmlDataDocument(ds);
    > return doc;
    >
     
    dbottjer, Dec 18, 2005
    #3
  4. John Doe

    John Doe Guest

    The actual web service does not connect to a database, it connects to a
    proprietary API gateway which also uses .Net. I apologize for the confusion,
    but I was trying to illustrate the fact that, as in the example, when
    returning an XML document with approximately 90 rows, that processor
    utilization spikes to about 50%. The actual format of the XML Document is
    similar to the following
    <quotes><quote symbol="msft" close="26.8"></quote></quotes>


    "dbottjer" wrote:

    > In the example you give your query users a "select *" I realize this is
    > likely just an example but I would look at the query you are using and make
    > sure you are returning only the data you need. For example, specify each
    > collumn you need and do not use a select *. Furthermore, use a where clause
    > to eliminate unwanted data.
    >
    > I would also suggest possibly applying indexes to the table or tables you
    > are returning data from. Indexes can help the database find the results you
    > are looking for faster.
    >
    > As previously suggested caching might be a good option to look at.
    >
    > Another suggestion would be to possibly look at using Data Transfermation
    > Objects (DTO) instead of a data set. Datasets can get rather large and do
    > have some overhead. Populating a collection of objects could possibly reduce
    > some overhead.
    >
    > "John Doe" wrote:
    >
    > > I have written a web service that returns an XmlDocument. The code is similar
    > > to the example below, except it returns an XmlDocument rather than an
    > > XmlDataDocument. When I run the service from the test harness in VS (or from
    > > a client page), CPU utilization on the Web server spikes to over 50% and
    > > returns quickly to around 0-5% after it has completed. I have tried the
    > > following:
    > > 1) Changed the type returned by the web service to type string.
    > > 2) Turned off Session State on the web server
    > > 3) Turned off logging on the Web server
    > > 4) Use anonymous authentication.
    > >
    > > I would like to limit the amount of processor used on the web server when
    > > the service is called. My client is concerned about this, because eventually
    > > there will be hundreds of concurrent users. What other steps can I take to
    > > limit the amount of CPU used?
    > >
    > > [WebMethod( Description="Returns Northwind Customers",EnableSession =false)]
    > > public XmlDocument GetData()
    > > {
    > >
    > > SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist
    > > Security Info=False;Initial Catalog=Northwind;Data Source=xxxxxxx");
    > > SqlDataAdapter cmd = new SqlDataAdapter("Select * from Customers",conn);
    > > DataSet ds = new DataSet();
    > > cmd.Fill(ds,"Orders");
    > > XmlDataDocument doc = new XmlDataDocument(ds);
    > > return doc;
    > >
     
    John Doe, Dec 18, 2005
    #4
  5. John Doe

    GCR Guest

    The problem is taht you still don't know if the spike is caused by the
    service logic or by the logic you called through the API! Maybe you could
    build and use a mock object instead of calling the API, to see if the high
    processing load is in the service logic.

    "John Doe" wrote:

    > The actual web service does not connect to a database, it connects to a
    > proprietary API gateway which also uses .Net. I apologize for the confusion,
    > but I was trying to illustrate the fact that, as in the example, when
    > returning an XML document with approximately 90 rows, that processor
    > utilization spikes to about 50%. The actual format of the XML Document is
    > similar to the following
    > <quotes><quote symbol="msft" close="26.8"></quote></quotes>
    >
    >
    > "dbottjer" wrote:
    >
    > > In the example you give your query users a "select *" I realize this is
    > > likely just an example but I would look at the query you are using and make
    > > sure you are returning only the data you need. For example, specify each
    > > collumn you need and do not use a select *. Furthermore, use a where clause
    > > to eliminate unwanted data.
    > >
    > > I would also suggest possibly applying indexes to the table or tables you
    > > are returning data from. Indexes can help the database find the results you
    > > are looking for faster.
    > >
    > > As previously suggested caching might be a good option to look at.
    > >
    > > Another suggestion would be to possibly look at using Data Transfermation
    > > Objects (DTO) instead of a data set. Datasets can get rather large and do
    > > have some overhead. Populating a collection of objects could possibly reduce
    > > some overhead.
    > >
    > > "John Doe" wrote:
    > >
    > > > I have written a web service that returns an XmlDocument. The code is similar
    > > > to the example below, except it returns an XmlDocument rather than an
    > > > XmlDataDocument. When I run the service from the test harness in VS (or from
    > > > a client page), CPU utilization on the Web server spikes to over 50% and
    > > > returns quickly to around 0-5% after it has completed. I have tried the
    > > > following:
    > > > 1) Changed the type returned by the web service to type string.
    > > > 2) Turned off Session State on the web server
    > > > 3) Turned off logging on the Web server
    > > > 4) Use anonymous authentication.
    > > >
    > > > I would like to limit the amount of processor used on the web server when
    > > > the service is called. My client is concerned about this, because eventually
    > > > there will be hundreds of concurrent users. What other steps can I take to
    > > > limit the amount of CPU used?
    > > >
    > > > [WebMethod( Description="Returns Northwind Customers",EnableSession =false)]
    > > > public XmlDocument GetData()
    > > > {
    > > >
    > > > SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Persist
    > > > Security Info=False;Initial Catalog=Northwind;Data Source=xxxxxxx");
    > > > SqlDataAdapter cmd = new SqlDataAdapter("Select * from Customers",conn);
    > > > DataSet ds = new DataSet();
    > > > cmd.Fill(ds,"Orders");
    > > > XmlDataDocument doc = new XmlDataDocument(ds);
    > > > return doc;
    > > >
     
    GCR, Dec 19, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Kavimandan

    Memory utilization for Windows services

    Jay Kavimandan, Oct 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,506
    Prasad
    Nov 2, 2004
  2. pt
    Replies:
    1
    Views:
    2,299
    Aaron W. West
    Jun 4, 2004
  3. Kevin Jackson
    Replies:
    1
    Views:
    427
    Alvin Bruney [MVP]
    May 28, 2004
  4. brahatha
    Replies:
    1
    Views:
    685
  5. John
    Replies:
    4
    Views:
    502
Loading...

Share This Page