如何测试IIS7同时请求执行限制

时间:2013-05-28 07:32:49

标签: delphi iis iis-7 delphi-xe3

我在虚拟机中的Windows Vista Ultimate上的IIS7上有一个示例ISAPI模块主机。根据{{​​3}},Windows Vista Ultimate的同时请求执行限制为10。我编写了一个示例应用程序来测试IIS7同时请求执行限制:

procedure TForm1.Button1Click(Sender: TObject);
const c_Max = 20;
var P: TProc<string>;
    o: TThread;
    i: integer;
    A: array of TThread;
begin
  P :=
    procedure(aValue: string)
    begin
      Memo1.Lines.Add(aValue);
    end;

  SetLength(A, c_Max);
  for i := Low(A) to High(A) do begin
    o := TMyThread.Create(P, edHostName.Text, Format('test%d', [i + 1]), True);
    o.FreeOnTerminate := True;
    A[i] := o;
  end;

  for o in A do
    o.Start;
end;

constructor TMyThread.Create(const aMethod: TProc<string>; const aHostName,
    aValue: string; const aCreateSuspended: boolean);
begin
  inherited Create(aCreateSuspended);
  FMethod := aMethod;
  FHostName := aHostName;
  FValue := aValue;
end;

procedure TMyThread.Execute;
var C: TSQLConnection;
    o: TServerMethods1Client;
    S: string;
begin
  C := TSQLConnection.Create(nil);
  C.DriverName := 'DataSnap';
  C.LoginPrompt := False;
  with C.Params do begin
    Clear;
    Values[TDBXPropertyNames.DriverUnit] := 'Data.DBXDataSnap';
    Values[TDBXPropertyNames.HostName] := FHostName;
    Values[TDBXPropertyNames.Port] := IntToStr(80);
    Values[TDBXPropertyNames.CommunicationProtocol] := 'http';
    Values[TDBXPropertyNames.URLPath] := 'MyISAPI/MyISAPI.dll';
  end;

  S := Format('%d=', [ThreadID]);
  try
    try
      C.Open;
      o := TServerMethods1Client.Create(C.DBXConnection);
      try
        S := S.Format('%s%s', [S, o.EchoString(FValue)]);
      finally
        o.Free;
      end;
    except
      on E: Exception do
        S := S.Format('%s%s', [S, E.Message]);
    end;
  finally
    Synchronize(
      procedure
      begin
        FMethod(S);
      end
    );
    C.Free;
  end;
end;

当我单击Button1时,Memo1显示20行字符串(ThreadID = EchoString的结果),即使我将常量变量c_Max更改为500,我仍然无法获得任何字符串行(ThreadID =异常消息) )显示在Memo1上。我的问题是如何测试IIS7同时请求执行限制?

0 个答案:

没有答案