Initial loading time too high

M

Manish Jain

Environment: Windows 2000 Server (SP4), ASP.Net/C# (Framework 1.1) Hardware:
PIII @ 700 MHz, 512 MB RAM
----------------------------------------------------------------------------
-------------------------------------------------------

I have developed a web application which I am deploying on above mentioned
environment. Problem is that when I run it for the first time after a Build,
then there is too much of CPU hogging. The Task Manager shows aspnet_wp.exe
and csc.exe as the culprits. This happens for each page, for the first time.

My understanding is that c-sharp compiler compiles the aspx pages the first
time. Subsequently, this overhead is not required till the next build.

Can somebody explain the reason behind the slow performance?
Is there any configuration/setting that I am ignoring?
Is it possible to do what csc.exe does at build time?

Basically, is there something that I can do to ensure less load time for the
first time. I am facing very low performace on my intranet, i am worried
about what would happen on the Internet.

Thanks and Regards

Manish
 
I

Ignacio Machin

Hi Manish,

You could improve the hardware or see if there are others applications
running in the same computer that are competing for power, other than that I
dont know what to do.

Cheers,
 
K

Kieran Benton

Manish,
Why should you worry about what "performance" is like once its on the wide
and open net? As you say, the slowdown only occurs the first time the
page/site is accessed and as long as you are the first person to test your
page, you will be the only person to experience the slow down!

Regards,
Kieran
 
N

Nicholas Paldino [.NET/C# MVP]

Manish,

From what I remember, I believe the recommendation is to have something
go through and view the pages so that they get compiled. From the section
of the .NET framework titled "Developing High-Performance ASP.NET
Applications":

If you have a large Web application, consider performing pre-batch
compilation. Batch compilation is performed whenever a first request is made
to a directory. If no page in the directory has been parsed and compiled,
this feature will parse and compile all pages in the directory in chunks to
provide better disk and memory usage. If this takes too long, a single page
will be parsed and compiled quickly so that the request can be processed.
This feature gives ASP.NET a performance benefit, since it compiles many
pages into a single assembly. Accessing a page from an assembly that is
already loaded is faster than loading a new assembly per page.
The downside of batch compilation is that if the server receives many
requests for pages that have not been compiled, performance can be poor
while the Web server parses and compiles them. To solve this problem, you
can perform pre-batch compilation. To do so, before your application goes
live, simply request a page from it — it does not matter which page. Then,
when users first access your site, the pages and their assembly will already
be compiled.

There is no easy mechanism to tell when batch compilation occurs. Wait until
the CPU idles or no more compiler processes, such as csc.exe (the C#
compiler) or vbc.exe (the Visual Basic compiler), are being launched.

Also try to avoid changing assemblies in the \bin directories for your
applications. Changing a page will cause a reparse and compilation of that
single page, but replacing an assembly in a \bin directory will cause a
whole new batch compile of that directory.

On larger scale sites with many pages, it may be better to design your
directory structure differently based on how often you plan to replace pages
or assemblies. Pages that will be changed infrequently could be stored in
the same directory and pre-batch compiled at specific times. Pages that
change more frequently should be in their own directories (a few hundred
pages at most in each) for fast compiles.

A Web application may contain many subdirectories. Batch compilation occurs
at the directory level, not the application level.



Hope this helps.
 
M

Manish Jain

My WebApp has around 1400 files right now, around 400 WebPages, lot of them
need parameters (querystring) to run.
Things are worse then this cause I have a login mechanism in place.
So cannot afford to view each an every page. And the product is in beta, so
there are lots and lots of changes everyday.
And I do not want to give the impression of slow website to my new users.
 
M

Manish Jain

Nicholas

Sorry for the late acknowledgement, and Thanks a lot for the detailed reply.
It was indeed what I was trying to know.

My problem is that my application has a login mechanism and since it is huge
(around 300 aspx/1200 total files), and I had to resort to using directories
for better organization. So I think I will have to login and run a page from
each directory before release.

You mentioned about pre-batch compilation. Can you tell me how to achieve
that?

Thanks again for the reply.

Manish



Nicholas Paldino said:
Manish,

From what I remember, I believe the recommendation is to have something
go through and view the pages so that they get compiled. From the section
of the .NET framework titled "Developing High-Performance ASP.NET
Applications":

If you have a large Web application, consider performing pre-batch
compilation. Batch compilation is performed whenever a first request is made
to a directory. If no page in the directory has been parsed and compiled,
this feature will parse and compile all pages in the directory in chunks to
provide better disk and memory usage. If this takes too long, a single page
will be parsed and compiled quickly so that the request can be processed.
This feature gives ASP.NET a performance benefit, since it compiles many
pages into a single assembly. Accessing a page from an assembly that is
already loaded is faster than loading a new assembly per page.
The downside of batch compilation is that if the server receives many
requests for pages that have not been compiled, performance can be poor
while the Web server parses and compiles them. To solve this problem, you
can perform pre-batch compilation. To do so, before your application goes
live, simply request a page from it - it does not matter which page. Then,
when users first access your site, the pages and their assembly will already
be compiled.

There is no easy mechanism to tell when batch compilation occurs. Wait until
the CPU idles or no more compiler processes, such as csc.exe (the C#
compiler) or vbc.exe (the Visual Basic compiler), are being launched.

Also try to avoid changing assemblies in the \bin directories for your
applications. Changing a page will cause a reparse and compilation of that
single page, but replacing an assembly in a \bin directory will cause a
whole new batch compile of that directory.

On larger scale sites with many pages, it may be better to design your
directory structure differently based on how often you plan to replace pages
or assemblies. Pages that will be changed infrequently could be stored in
the same directory and pre-batch compiled at specific times. Pages that
change more frequently should be in their own directories (a few hundred
pages at most in each) for fast compiles.

A Web application may contain many subdirectories. Batch compilation occurs
at the directory level, not the application level.



Hope this helps.




--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Manish Jain said:
Environment: Windows 2000 Server (SP4), ASP.Net/C# (Framework 1.1) Hardware:
PIII @ 700 MHz, 512 MB RAM
--------------------------------------------------------------------------
--
-------------------------------------------------------

I have developed a web application which I am deploying on above mentioned
environment. Problem is that when I run it for the first time after a Build,
then there is too much of CPU hogging. The Task Manager shows aspnet_wp.exe
and csc.exe as the culprits. This happens for each page, for the first time.

My understanding is that c-sharp compiler compiles the aspx pages the first
time. Subsequently, this overhead is not required till the next build.

Can somebody explain the reason behind the slow performance?
Is there any configuration/setting that I am ignoring?
Is it possible to do what csc.exe does at build time?

Basically, is there something that I can do to ensure less load time for the
first time. I am facing very low performace on my intranet, i am worried
about what would happen on the Internet.

Thanks and Regards

Manish
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top