Reputation: 29
I need your help.
I made a console application with C# net.4.5 ans AWSSDK V3.3 , to configure my intance at startup.
My probleme is, at the first start of my instance (windows server 2008r2) the application starting EXTREMELY slowly and running EXTREMELY slowly.
Indeed, i use "Task scheduler" to start the app at boot time.
When i reboot the instance or restart (or even fresh start) the app, everithing work fine.
When i start the app at boot time with Task scheduler: the task taking over than 5 minutes! to complete. (What a cold start!)
I have delayed the start of my app (with a /timout .bat) (90secondes) > app still extremly slow...
So, now i have to run hundred of spot-instances with this startup app.... if i loose 5 minutes at startup on each instance, i'll loose a looot of money!
What do you think about my case? do you think i'am right about the .net framworks pre-loading? is it possible to make it load faster?
i'am aware of ngen.exe, i tried it on the .exe and dlls. but the problem still the same. i think that the problem is more global, not specific to my app.
For your information:
in my app From the SDK i use:
Credentials are stored ine app.config
All this class are called one time. (no retry loop if failling). I mean, if there is no internet the app crash or return Exception. The app is made in VS 2015, and the AWSSDK dlls are in the root folder of the .exe
Thanks you, for your help!
---------------------------- edit ------------------
I did a simple test with a simple clean console (Visual studio 2015 template) code (writing 100 txt file on C:). I ran the programme at startup with Task scheduler, and it toke 5 minutes to accomplish this huge task.... so it seem that the probleme is not my code.
edit: I also tried the simple test app with ".net framework 3.5 client". same thing... app hang for 4 minutes then do the job. (6 minutes in total).
@MaLiN2223 May be making a service rather than a console app is a solution... i should try. What my startup app do:
Donwload files on amazon S3
get instance infos from aws-sdk
Start Or Stop services
Change value in .ini
Mount network drive
reading xml value
start applications
for your information, the test code:
using System;
using System.IO;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 100; i++)
{
Console.Write("Writting file nb: " + i.ToString());
File.Create(@"C:\test_" + i.ToString() + ".txt");
}
log();
Console.ReadKey();
}
static void log()
{
using (StreamWriter writer = new StreamWriter("C:\\test_log.txt"))
{
var uptime02 = new PerformanceCounter("System", "System Up Time");
uptime02.NextValue(); //Call this an extra time before reading its value
var timeTowrite = TimeSpan.FromSeconds(uptime02.NextValue());
writer.WriteLine(timeTowrite);
}
}
}
}
Upvotes: 1
Views: 1353
Reputation: 29
Okay..., I found the problem and the answer!
The problem is that "task scheduler" launch the applications with a priority set by default to "below to normal" .... Obviously, my application is slower because many high priority processes are launched at startup...
It is impossible to change the priority directly in task schedelur. It must be done by exporting the task in XML, modifying it, and re-importing it.
Thanks you.
Upvotes: 1