asp.netiissignalrwindows-processworker-processes

Is there a limit on the number of processes, which can be started in an ASP.NET application?


I have a signalr server which is hosted in IIS. There is a function in the hub which starts 600 processes in windows and then kills them.

    //start 600 processes
        for (int i = 0; i < 600; i++)
        {
            try
            {
                Process myProcess = Process.Start(startInfo);
                proclist.Add(myProcess);
                Task.Delay(10).Wait();
            }
            catch(Exception e)
            {
                 feedback = "Process " + i + " cannot be started: " + e.Message;
                 break;
            }
            feedback = "All processes are running.";
        }
        //kill them
        foreach (var proc in proclist)
        {
            try
            {
                proc.Kill();
                Task.Delay(10).Wait();
            }
            catch (Exception e)
            {
                feedback = "Process " + proclist.IndexOf(proc) + " cannot be killed: " + e.Message;
                break;
            }
            feedback = "All Processes are killed.";
        }

However, when I call this function in Client I get an Exception whiling killing the processes:

Process 104 cannot be killed: Die Anforderung kann nicht verarbeitet werden, da der Prozess beendet wurde(The request cannot be proceeded, because the process is already terminated.)

It seems that I can only keep 104 processes runing. And the rest of them terminate immediately after start.

So I would like to ask whether anyone knows how to start more procecces in an ASP.NET application.

I will appreciate it very much if someone can help me. Thanks!


Solution

  • I strongly suggest you do not execute 600 (or any multiple of hundred) processes under ASP.NET. You will really strain the resources on the Aspnet_wp.exe process which could hurt the performance of the IIS box.

    You need to re-think the design.

    If this was me, I would consider creating an external process outside of ASP.NET which could do the hard work for you. For example, maybe you can create a Windows service (or even just a .NET console application running on the server) that waits (i.e. listens) on a file system folder for a file (you can name the file anything you like e.g. start.txt) to be created which you could do when a request to your website is made. That service will then execute the 600 exe files for you.

    I'm not familiar with lasttest, so my suggestion might not be adequate. However, I do not believe you will achieve what you are looking for using your current design. It's going to hurt performance, and in fact, I'm not suprised that a limit of running processes has been reached. I do not know of any documentation that points to how many exe files you can run in Aspnet_wp.exe, but that's likely because the ASP.NET team never expected anyone to attempt this.