I am trying to imitate a scenario when 300,000 users access the server. Therefore, I am trying to create pseudo clients by repeatedly accessing the server from parallel threads.
But the first hurdle that needs to be cleared is the ability to run 300,000 threads on a PC? Here is the code that I use to see how many maximum threads I can get, and then replace the test function with the actual function:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace CheckThread { class Program { static int count; public static void TestThread(int i) { while (true) { Console.Write("\rThread Executing : {0}", i); Thread.Sleep(500); } } static void Main(string[] args) { count = 0; int limit = 0; if (args.Length != 1) { Console.WriteLine("Usage CheckThread <number of threads>"); return; } else { limit = Convert.ToInt32(args[0]); } Console.WriteLine(); while (count < limit) { ThreadStart newThread = new ThreadStart(delegate { TestThread(count); }); Thread mythread = new Thread(newThread); mythread.Start(); Console.WriteLine("Thread # {0}", count++); } while (true) { Thread.Sleep(30*1000); } }
Now what I'm trying may be unrealistic, but still, if there is a way out, and you know, then please help me.
Andy_MSFT
source share