Poor performance under IIS

Discussion in 'ASP .Net' started by Ilyas, Jun 20, 2008.

  1. Ilyas

    Ilyas Guest

    Hi all

    I have an application which brings back 1000 records from a sql server
    database. Under the local asp.net development server provided with
    Visual Studio 2008, it takes about 1.8 seconds

    When I place this application in IIS it takes 16 seconds for the exact
    bit of code. I have narrowed the code down to loopoing around the
    dataset and creating an object for every row in the dataset. My
    question is why does it take so long under IIS but not under the local
    asp.net development server?

    Any ideas? How can I get this 16 seconds down to a more acceptable
    level eg 2-3 seconds? Is this a configuration issue? I have tried
    deploying this to 2 different IIS servers and the same bit of code
    takes 16 seconds on both IIS boxes

    The application is developed using .net framewor 3.5 and c#, asp.net

    Ilyas
     
    Ilyas, Jun 20, 2008
    #1
    1. Advertising

  2. Ilyas

    Ilyas Guest

    On 20 Jun, 17:02, "Mark Rae [MVP]" <> wrote:
    > "Ilyas" <> wrote in message
    >
    > news:...
    >
    > > I have an application which brings back 1000 records from a sql server
    > > database. Under the local asp.net development server provided with
    > > Visual Studio 2008, it takes about 1.8 seconds

    >
    > > When I place this application in IIS it takes 16 seconds for the exact
    > > bit of code. I have narrowed the code down to loopoing around the
    > > dataset and creating an object for every row in the dataset. My
    > > question is why does it take so long under IIS but not under the local
    > > asp.net development server?

    >
    > > Any ideas? How can I get this 16 seconds down to a more acceptable
    > > level eg 2-3 seconds? Is this a configuration issue? I have tried
    > > deploying this to 2 different IIS servers and the same bit of code
    > > takes 16 seconds on both IIS boxes

    >
    > 1) When the code is running on the development server, is the database it's
    > connecting to also on the development server?
    >
    > 2) When the code is running on the remote server, is the database it's
    > connecting to on a different remote server? If so, have you got networking
    > issues. Also, what database is it and how are you connecting to it?
    >
    > 3) Can you be a bit more specific about what you mean by "looping around the
    > dataset"? What is actually happening here?
    >
    > 4) Can you confirm that, wherever the bottleneck is, it's not in the actual
    > retrieval of the data from the database...?
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net


    They are no networking issues as there is no problems fetching the
    data.

    Yes the same database is being used throughtout. I have used Sql
    Prolfiler and can definatly confirm that its not sql server causing
    the delay. Sql server splits out the record in under a second

    By looping around the dataset, I mean for each row in the dataset,I am
    creating a business object, and setting its properties. The problem is
    when the code to do this is deployed in IIS the code it takes about 16
    seconds while under asp.net development server (built in visual studio
    2008 web server) it takes 2 seconds. I have determined this using
    trace.axd with custom messages that I have written at various stages
    of this process. Why is there such a big difference in the times?

    Surly IIS would give better timings than this as its an enterprise web
    server...?
     
    Ilyas, Jun 21, 2008
    #2
    1. Advertising

  3. re:
    !> when the code to do this is deployed in IIS the code it takes about 16
    !> seconds while under asp.net development server (built in visual studio
    !> 2008 web server) it takes 2 seconds. I have determined this using
    !> trace.axd with custom messages that I have written at various stages
    !> of this process. Why is there such a big difference in the times?

    How isolated is your application in the IIS Server ?

    In the ASP.NET Development Server, your app can use up to 100% of the CPU time.

    In the IIS Server :

    1. Is the app running in its own Application Pool ?
    If the app is sharing the Application Pool with other applications,
    that could have an impact on performance.

    Simply isolating the app in its own App Pool will improve performance.

    2. How many processors does the IIS Server have ?
    If the application is critical enough, and you have a quad processor,
    for example, you could allocate 2 processors to ASP.NET

    Look up the processModel and cpuMask configuration parameters in machine.config.

    ASP.NET launches one worker process for each qualified CPU.

    If the webGarden attribute is configured to true,
    doing this limits worker processes to the number of qualified CPUs.

    The maximum for worker processes is equal to the number of CPUs.
    If webGarden is false, this attribute is ignored and only one worker process will run.

    This is the default behavior, which is why it needs to be configured
    to be able to take advantage of your unused processing power.

    Be careful when configuring the cpuMask, as it needs a hexadecimal value.
    The default is "0xffffffff", which enables one processor only.

    The cpuMask hexadecimal value 0x0d represents the bit pattern 1101.

    On a computer with four CPUs, this indicates that ASP.NET
    processes can be scheduled on CPUs 0, 2, and 3, but not on CPU 1.

    Make sure you use the correct hexadecimal value desired if you're configuring the cpuMask.

    Note that, if you want to use the cpuMask, you must set "Webgarden" to true.

    Otherwise, the cpuMask parameters will be ignored, and Windows will schedule
    cpu usage to its convenience, which means that other processes might get more
    priority, instead of ASP.NET being the most prioritized Windows process.

    See :
    http://msdn.microsoft.com/en-us/library/5dws599a.aspx

    <quote>
    When an ASP.NET Web page calls an external resource, such as when performing database access requests,
    the page request stops until the external resource responds, freeing the CPU to process other threads.

    If another request is waiting to be processed and a thread is
    free in the thread pool, the waiting request begins processing.

    The result can be a high number of concurrently executing requests and many waiting threads
    in the ASP.NET worker process or application pool, which hinders the Web server's throughput,
    adversely affecting performance.

    To work around that, you can manually set the limit on the number of threads in the process by changing
    the MaxWorkerThreads and MaxIOThreads attributes in the processModel section of the machine.config file.
    </quote>

    Be very careful when you do this...and test each Max parameter you change, in isolation.

    You might want to, initially, set the processModel to autoConfig="true".
    The built-in parameters usually provide enough performance.

    You did not reply to Mark when he asked you whether SQL Server
    is located on the same machine as the IIS web server.

    If you need more processing power, and your IIS server has 2 processors, and if SQL Server
    is located on the same machine as the IIS web server, you might want to set the cpuMask
    so that one processor is used by ASP.NET and the other is specialized for SQL Server.

    You can set the SQL Server's processor affinity in Task Manager.

    Also in Task Manager, you can increase the Priority for the ASP.NET process (w3wp.exe)for your app.
    That will effectively dedicate more cpu time to ASP.NET/IIS.

    The throughput gains by configuring the above suggestions are mind-boggling.

    3. Have you disabled Debug mode for the application ?
    IIS responds more slowly when applications are running in Debug mode.
    Make sure you disable debugging for the IIS application in the app's web.config

    I hope these tips help you configure your IIS web server to achieve more throughput.



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Ilyas" <> wrote in message
    news:...
    > On 20 Jun, 17:02, "Mark Rae [MVP]" <> wrote:
    >> "Ilyas" <> wrote in message
    >>
    >> news:...
    >>
    >> > I have an application which brings back 1000 records from a sql server
    >> > database. Under the local asp.net development server provided with
    >> > Visual Studio 2008, it takes about 1.8 seconds

    >>
    >> > When I place this application in IIS it takes 16 seconds for the exact
    >> > bit of code. I have narrowed the code down to loopoing around the
    >> > dataset and creating an object for every row in the dataset. My
    >> > question is why does it take so long under IIS but not under the local
    >> > asp.net development server?

    >>
    >> > Any ideas? How can I get this 16 seconds down to a more acceptable
    >> > level eg 2-3 seconds? Is this a configuration issue? I have tried
    >> > deploying this to 2 different IIS servers and the same bit of code
    >> > takes 16 seconds on both IIS boxes

    >>
    >> 1) When the code is running on the development server, is the database it's
    >> connecting to also on the development server?
    >>
    >> 2) When the code is running on the remote server, is the database it's
    >> connecting to on a different remote server? If so, have you got networking
    >> issues. Also, what database is it and how are you connecting to it?
    >>
    >> 3) Can you be a bit more specific about what you mean by "looping around the
    >> dataset"? What is actually happening here?
    >>
    >> 4) Can you confirm that, wherever the bottleneck is, it's not in the actual
    >> retrieval of the data from the database...?
    >>
    >> --
    >> Mark Rae
    >> ASP.NET MVPhttp://www.markrae.net

    >
    > They are no networking issues as there is no problems fetching the data.
    >
    > Yes the same database is being used throughtout. I have used Sql
    > Prolfiler and can definatly confirm that its not sql server causing
    > the delay. Sql server splits out the record in under a second
    >
    > By looping around the dataset, I mean for each row in the dataset,I am
    > creating a business object, and setting its properties. The problem is
    > when the code to do this is deployed in IIS the code it takes about 16
    > seconds while under asp.net development server (built in visual studio
    > 2008 web server) it takes 2 seconds. I have determined this using
    > trace.axd with custom messages that I have written at various stages
    > of this process. Why is there such a big difference in the times?
    >
    > Surly IIS would give better timings than this as its an enterprise web server...?
     
    Juan T. Llibre, Jun 21, 2008
    #3
  4. Ilyas

    John Rivers Guest

    1800 milliseconds is a very long time for a web response
    anything longer than 100 milliseconds is bad news

    profile your code using NProf or add some timing code - then you have
    your answer

    juan has highlighted some interesting points but playing with those
    settings is just guesswork

    find the problem - then fix it

    IMO datasets should be avoided as they very inefficient
     
    John Rivers, Jun 22, 2008
    #4
  5. re:
    !> profile your code using NProf or add some timing code - then you have your answer

    John, Ilyias already knows where the problem is, according to what he posted :

    !> I have narrowed the code down to looping around the
    !> dataset and creating an object for every row in the dataset.

    The problem, as I see it, is that Ilyias stated that the *same*
    code works slower in IIS than in the ASP.NET Dev Server.

    His question boils down to :
    !> why does it take so long under IIS but not under the local asp.net development server?

    That's why I suggested a few things he could look into, germane to his problem.

    re:
    !> juan has highlighted some interesting points but playing with those settings is just guesswork

    Profiling under IIS *will* reveal the problem, as you say.
    The *solution*, however, is probably found in the tips I suggested.

    The tips offered target the possible causes for the same
    code to work slower in IIS than in the ASP.NET Dev Server.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "John Rivers" <> wrote in message
    news:...
    > 1800 milliseconds is a very long time for a web response
    > anything longer than 100 milliseconds is bad news
    >
    > profile your code using NProf or add some timing code - then you have
    > your answer
    >
    > juan has highlighted some interesting points but playing with those
    > settings is just guesswork
    >
    > find the problem - then fix it
    >
    > IMO datasets should be avoided as they very inefficient
     
    Juan T. Llibre, Jun 22, 2008
    #5
  6. Ilyas

    John Rivers Guest

    randomly changing settings in IIS till the problem stops = guessing

    none of the things you mentioned would cause such a huge slow down

    he does not know where the delay is EXACTLY

    if he profiled or timed his code he could identify a method call where
    a delay is caused
    from there he could determine the actual cause of the delay

    it is probably some nonsense concerning microsoft networking or
    authentication or that pig Kerberos

    combining the data from profiling his code with a sql profile he could
    match up the timestamps and KNOW
    for sure the delay occurs after the dataset is filled etc.

    the real challenge in developing is not writing code - but debugging
    and profiling it

    use NProf - use SQL Profiler - use WireShark - use TDIMon etc. etc.
    and you will find a real answer

    plus you will learn the skills you need to debug ANYTHING

    thrashing around in IIS settings like a wild bull in a china shop
    hoping your problem will disappear is not the right approach
     
    John Rivers, Jun 23, 2008
    #6
  7. re:
    !> randomly changing settings in IIS till the problem stops = guessing
    !> none of the things you mentioned would cause such a huge slow down

    For someone who has a grand total of 106 posts to
    43 newsgroups, in the last 3 years, you sure are opinionated.

    Can't you consider that you might, possibly,
    not be as correct as you think you are ?





    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "John Rivers" <> wrote in message
    news:...
    > randomly changing settings in IIS till the problem stops = guessing
    >
    > none of the things you mentioned would cause such a huge slow down
    >
    > he does not know where the delay is EXACTLY
    >
    > if he profiled or timed his code he could identify a method call where
    > a delay is caused
    > from there he could determine the actual cause of the delay
    >
    > it is probably some nonsense concerning microsoft networking or
    > authentication or that pig Kerberos
    >
    > combining the data from profiling his code with a sql profile he could
    > match up the timestamps and KNOW
    > for sure the delay occurs after the dataset is filled etc.
    >
    > the real challenge in developing is not writing code - but debugging
    > and profiling it
    >
    > use NProf - use SQL Profiler - use WireShark - use TDIMon etc. etc.
    > and you will find a real answer
    >
    > plus you will learn the skills you need to debug ANYTHING
    >
    > thrashing around in IIS settings like a wild bull in a china shop
    > hoping your problem will disappear is not the right approach
     
    Juan T. Llibre, Jun 23, 2008
    #7
  8. Ilyas

    John Rivers Guest

    > For someone who has a grand total of 106 posts to
    > 43 newsgroups, in the last 3 years, you sure are opinionated.


    Yes of course - that is the most important thing

    not years of study - not years of practical experience - but number of
    posts!
    How very convenient for you - in your own value system you are king

    You are just hoping for a lucky guess so you can get a "ooh thanks
    Juan you are the best" post

    And what do you propose the OP should do after trying your ideas and
    the problem remains?

    I could easily get a list of 100 random changes you could make to
    IIS / Windows / SQL Server etc. etc.
    that might fix the problem - should he try those too?
    In what order should he try them? What combinations?

    If you are so great let us see your work - URLs please
     
    John Rivers, Jun 24, 2008
    #8
  9. re:
    !> what do you propose the OP should do after trying your ideas and the problem remains?

    What will you do if he tries them ...and they work ?
    After all, the techniques I outlined have been *proven* to increase throughput.

    re:
    !> random changes

    What leads you to believe that the fixes proposed are "random changes" ?
    Every suggestion I made will improve performance.

    re:
    !> If you are so great let us see your work - URLs please

    Here's a few :

    http://www.amazon.com/Beginning-ASP...=sr_1_5?ie=UTF8&s=books&qid=1214281145&sr=1-5

    http://www.amazon.com/Beginning-ASP...=sr_1_3?ie=UTF8&s=books&qid=1214281145&sr=1-3

    http://www.amazon.com/Beginning-ASP...=sr_1_2?ie=UTF8&s=books&qid=1214281145&sr=1-2

    http://www.amazon.com/Beginning-Act...=sr_1_4?ie=UTF8&s=books&qid=1214281145&sr=1-4

    http://www.amazon.com/Beginning-Act...=sr_1_1?ie=UTF8&s=books&qid=1214281145&sr=1-1

    Now, show me yours.

    Uh-oh, I already know : you don't have any, and are trying out for a career in being
    antagonistic online about people and programming issues that you hardly know about.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "John Rivers" <> wrote in message
    news:...
    >> For someone who has a grand total of 106 posts to
    >> 43 newsgroups, in the last 3 years, you sure are opinionated.

    >
    > Yes of course - that is the most important thing
    >
    > not years of study - not years of practical experience - but number of
    > posts!
    > How very convenient for you - in your own value system you are king
    >
    > You are just hoping for a lucky guess so you can get a "ooh thanks
    > Juan you are the best" post
    >
    > And what do you propose the OP should do after trying your ideas and
    > the problem remains?
    >
    > I could easily get a list of 100 random changes you could make to
    > IIS / Windows / SQL Server etc. etc.
    > that might fix the problem - should he try those too?
    > In what order should he try them? What combinations?


    > If you are so great let us see your work - URLs please
     
    Juan T. Llibre, Jun 24, 2008
    #9
  10. Ilyas

    John Rivers Guest

    "After all, the techniques I outlined have been *proven* to increase
    throughput."
    he does not have a "throughput" problem - he has a serious blocking
    issue with one request
    your tips are for increasing throughput of a busy web server

    BTW those urls you provided are for books - not websites
    All of which include the word "Beginning" in the title and I would not
    buy or recommend

    I do not need to provide URLs because I am not camping on this
    newsgroup like I own it
    handing out copy and paste responses which are mostly rubbish. You are
    not helping anybody.

    What actual commercial experience do you have?

    I am only antagonistic towards you because you give bad information
    and I doubt your skill, knowledge and experience.

    Three years was the last time I visited this newsgroup and you were a
    fool then - to quote you:
    "If you intend to use IHttpHandlers for a web app, exactly how are you
    going to do that without an ASPX page?"
    you may as well have written "I do not know anything about ASP.NET"

    In three years not much has improved - if you have time to write all
    these posts and co-author books why have you not created some
    demonstration websites - showing how it should be done?
     
    John Rivers, Jun 24, 2008
    #10
  11. re:
    !> You are not helping anybody

    I have HUNDREDS of thank-you notes from grateful
    programmers whom I have given very specific help.

    You love to flame, huh ?

    Talk to yourself from now on.

    <plonk>



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "John Rivers" <> wrote in message
    news:...
    > "After all, the techniques I outlined have been *proven* to increase
    > throughput."
    > he does not have a "throughput" problem - he has a serious blocking
    > issue with one request
    > your tips are for increasing throughput of a busy web server
    >
    > BTW those urls you provided are for books - not websites
    > All of which include the word "Beginning" in the title and I would not
    > buy or recommend
    >
    > I do not need to provide URLs because I am not camping on this
    > newsgroup like I own it
    > handing out copy and paste responses which are mostly rubbish. You are
    > not helping anybody.
    >
    > What actual commercial experience do you have?
    >
    > I am only antagonistic towards you because you give bad information
    > and I doubt your skill, knowledge and experience.
    >
    > Three years was the last time I visited this newsgroup and you were a
    > fool then - to quote you:
    > "If you intend to use IHttpHandlers for a web app, exactly how are you
    > going to do that without an ASPX page?"
    > you may as well have written "I do not know anything about ASP.NET"
    >
    > In three years not much has improved - if you have time to write all
    > these posts and co-author books why have you not created some
    > demonstration websites - showing how it should be done?
    >
     
    Juan T. Llibre, Jun 24, 2008
    #11
  12. Ilyas

    John Rivers Guest

    - Juan says randomly change settings in IIS - you might get lucky
    - John says use profiling and timers and debugging tools to determine
    the EXACT cause of the issue and then resolve it
    - Juan says because he has posted so many messages on the internet he
    is qualified to say that John's approach should NOT be used

    Here is another thank-you note from me "Thankyou for providing a few
    moments amusement and making me feel superior"

    When you get round to building something using ASP.NET please let me
    know
     
    John Rivers, Jun 24, 2008
    #12
  13. Ilyas

    John Rivers Guest

    I am not "flaming"

    I am criticising you - with good reason

    You have the opportunity to respond to the criticism and either:

    - illustrate why I am wrong - and I will learn something
    - or agree that I have a point - and you will learn something

    But you have not done either - you have just run away

    And this topic will be here for the next 10 years as proof of your
    folly
     
    John Rivers, Jun 24, 2008
    #13
    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. =?Utf-8?B?QmlsbCBUaG9ybmU=?=

    ASP.NET Poor performance with long-running COM object calls

    =?Utf-8?B?QmlsbCBUaG9ybmU=?=, Oct 12, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    665
    =?Utf-8?B?QmlsbCBUaG9ybmU=?=
    Nov 15, 2004
  2. Helge

    W3WP poor performance

    Helge, Mar 14, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,435
    Scott Allen
    Mar 14, 2005
  3. dan
    Replies:
    1
    Views:
    329
    Christophe Vanfleteren
    Apr 6, 2004
  4. meo

    IIS and poor performance

    meo, Feb 12, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    388
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 12, 2007
  5. Whiskey Romeo Lima
    Replies:
    1
    Views:
    571
    Whiskey Romeo Lima
    Jul 16, 2009
Loading...

Share This Page