Showing posts with label runs. Show all posts
Showing posts with label runs. Show all posts

Thursday, March 29, 2012

Performance problems using ASP.NET 2.0

I have just built my first ASP.NET v2.0 app and have it running on a 3 server web farm that runs several other ASP.NET v1.1 apps. The v1.1 apps run great, but the new v2.0 app always seems to run very slowly when first connecting to the site, even if other users have already visited the site. I believe I have pre-compiled the site, and even if I visit each server in turn to ensure the app has been compiled before hitting the load-balanced url, the site just runs very slowly. On our development machines the site runs very quickly, so the poor performance is a bit of a mystery.

The servers in the farm are running Windows 2003 Server and the machine.config on each server has been updated to syncronize the machine keys.

Check the event viewer to see if the app pool is restarting itself. Some people had problems with the application shutting down and if that's your case then when the app (aspnet) restarts itself the code has to recompile. Any other details that you might find, will help on directing you towards the right path.

hi

are u working with directory. The asp.net 2.0 application restart as soon as the directory structure changes. see the post below

http://vikramlakhotia.com/Post.aspx?postID=6

Hope this helps

Vikram

Vikram's Blog


Did not know that. If that's the case that's a huge bug on asp.net 2.0. It should be reported. Maybe there's a setting on the Machine.Config for the application not to restart when the directory structure changes.
There was nothing in the event viewer for all three servers (relating to asp.net anyway). The slow responses almost feel like every page request is causing the application to be re-built...

I don't know what else to tell you. Maybe you have indexing on and it's getting ahold of the files and thus restarting. Just throwing one out there.

Try creating another app and see how it behaves. If it behaves normal, then the problem is related to your application.

Monday, March 26, 2012

Performing an Operation Once a Day

I want to write a script that runs just once in a day.
Like i want to add a poll of the day or send all emails after one day or something like that then how can i do?
I thought of threading but if the web application closes and then on its start how would it know if the actions have been taken? do I have to store them in some files like last poll update time etc.
Is there a better way of doing this? Moreover can i make a class that is visible to all the sessions (just like application variables) and any script can call that class or its member functions.There are several ways to go about this. You could have the web app fire the tasks (yes, you'd have to store the status in a file or database somewhere), but because ASP.NET may restart itself, the application may shut down, etc., you won't be able to control when your daily processes run. If you are simply adding content to a database, you might choose to schedule a database job to run at a specific time. You could use the Windows scheduler to fire off an exe or to run some VBScript via WSH at a predetermined time. Or, you may choose to create a Windows service to coordinate execution of each task.
To answer your second question: yes, you can create a class that is visible to all sessions. A class built using the singleton design pattern will accomplish this, with the side-effect of also being accesible to your non-HttpContext daily tasks.

Thanks for the reply.
Yes, choosing a database schedule is suitable for database jobs. I dont have direct access to my server ( i have shared hosting), so i dont think i can write a windows scheduler. Moreover i would like to write a generic script that will work on any client machine.
I didnt quite understand the second point. What is a class built on a singleton design? The side effect that it is accessible to non httpcontext tasks mean it can be accessed without the http request also?
I did the same thing with an application I wrote, this was delivered on a shared hosting plan.
I added a little script to the homepage which checked if todaysactivity had been completed, if not, it did it and then changed theflag.
Of course, someone had to visit the homepage at least once a day - butthat wasn't a problem, since the customer visited it every hour anyway.
We had two versions - one which stored data in a database, another stored the flag in an XML file.

Ya this is a good idea. I had thought of making a page that the web team will visit each day, which will execute the scripts. This way i can perform the operations.
Is it possible to make a class that sends email. This must be visible to the entire application. How can i do that?
Yes, things will get a bit trickier in a shared hosting environment. Your only option may be to have a page check a status flag and kickoff the script as has been suggested and, as long as thight scheduling is not required, should work just fine.
A singleton class can only ever have one instance, meaning that data can be easily shared between objects, etc. The advantage to using this approach versus the ASP.NET Application object is that other, non-web pieces of your application can gain access to the object. If you'd like to learn more about singleton, referenceDesign Patterns or theMS P&P website.


Thanks. The link was of great help.