views:

56

answers:

1

Hello everyone,

I am using the following code to try to test whether network consumption (monitored from network tab of task manager) will increase if I increase the concurrent connection number (i.e. the ClientCount application configuration value). But I find even if I increase client count from 100 to 500, the network consumption is still the same (around 3%-4%, from both client and server side). Any ideas what is wrong? I want to prove if concurrent number increases from client side, both client and server network consumption will crease.

Here is my application config and client side code. The URL is a wmv file hosted in IIS 7.0 bit rate throttling control on another machine in local LAN. I am using VSTS 2008 + C# + .Net 3.5 to develop a console application as client.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.net>
    <connectionManagement>
      <add address="*" maxconnection="1000000" />
    </connectionManagement>
  </system.net>
  <appSettings>
    <add key="URL" value="http://labtest2/test.wmv"/&gt;
    <add key="ClientCount" value="100"/>
    <add key="Timeout" value="3600"/>
  </appSettings>
</configuration>

class Program
{
    private static int ClientCount = 100;
    private static string TargetURL = String.Empty;
    private static int Timeout = 200;

    static void PerformanceWorker()
    {
        Stream dataStream = null;
        HttpWebRequest request = null;
        HttpWebResponse response = null;
        StreamReader reader = null;
        try
        {
            request = (HttpWebRequest)WebRequest.Create(TargetURL);
            request.Timeout = Timeout * 1000;
            request.Proxy = null;
            response = (HttpWebResponse)request.GetResponse();
            dataStream = response.GetResponseStream();
            reader = new StreamReader(dataStream);

            // 1 M at one time
            char[] c = new char[1000 * 1000];

            while (reader.Read(c, 0, c.Length) > 0)
            {
                Console.WriteLine(Thread.CurrentThread.ManagedThreadId + ":\t" + c[0]);
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
        }
        finally
        {
            if (null != reader)
            {
                reader.Close();
            }
            if (null != dataStream)
            {
                dataStream.Close();
            }
            if (null != response)
            {
                response.Close();
            }
        }
    }

    static void Main(string[] args)
    {
        TargetURL = ConfigurationSettings.AppSettings["URL"];
        ClientCount = Int32.Parse(ConfigurationSettings.AppSettings["ClientCount"]);
        Timeout = Int32.Parse(ConfigurationSettings.AppSettings["Timeout"]);
        Thread[] workers = new Thread[ClientCount];
        for (int i = 0; i < ClientCount; i++)
        {
            workers[i] = new Thread((new ThreadStart(PerformanceWorker)));
        }

        for (int i = 0; i < ClientCount; i++)
        {
            workers[i].Start();
        }

        for (int i = 0; i < ClientCount; i++)
        {
            workers[i].Join();
        }           

        return;
    }
}

thanks in advance, George

+1  A: 

Maybe there's a limit of maximal concurrent calls on the server, can you check it? Some servers allow e.g. 10 parallel connections (or actually they can also be single-threaded with 1 concurrent call only).

Thomasek
Where do you mean the limitation on server side to check? web.config or in IIS manager?
George2
I have tried on IIS 7 for Windows Server 2008 it works fine. But on IIS 7 for Windows 7, it has issues, why?
George2