By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

Poor performance under IIS

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
12 Replies


P: n/a
"Ilyas" <il***@igsoftwaresolutions.co.ukwrote in message
news:36**********************************@t54g2000 hsg.googlegroups.com...
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 MVP
http://www.markrae.net

Jun 27 '08 #2

P: n/a
On 20 Jun, 17:02, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Ilyas" <il...@igsoftwaresolutions.co.ukwrote in message

news:36**********************************@t54g2000 hsg.googlegroups.com...
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...?
Jun 27 '08 #3

P: n/a
"Ilyas" <il***@igsoftwaresolutions.co.ukwrote in message
news:e0**********************************@m44g2000 hsc.googlegroups.com...
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?
Impossible to tell without knowing more about what the business objects are
and how you're creating them...
Surly IIS would give better timings than this as it's an enterprise web
server...?
Not necessarily... When you're using the VS.NET development server, you're
the only user. Is the IIS box being used for anything else other than this
app...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4

P: n/a
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" <il***@igsoftwaresolutions.co.ukwrote in message
news:e0**********************************@m44g2000 hsc.googlegroups.com...
On 20 Jun, 17:02, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"Ilyas" <il...@igsoftwaresolutions.co.ukwrote in message

news:36**********************************@t54g200 0hsg.googlegroups.com...
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...?


Jun 27 '08 #5

P: n/a
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
Jun 27 '08 #6

P: n/a
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" <fi*****@btinternet.comwrote in message
news:2e**********************************@c58g2000 hsc.googlegroups.com...
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

Jun 27 '08 #7

P: n/a
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
Jun 27 '08 #8

P: n/a
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" <fi*****@btinternet.comwrote in message
news:37**********************************@j22g2000 hsf.googlegroups.com...
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

Jun 27 '08 #9

P: n/a
"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?

Jun 27 '08 #10

P: n/a
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" <fi*****@btinternet.comwrote in message
news:be**********************************@x35g2000 hsb.googlegroups.com...
"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?

Jun 27 '08 #11

P: n/a
- 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


Jun 27 '08 #12

P: n/a
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
Jun 27 '08 #13

This discussion thread is closed

Replies have been disabled for this discussion.