Thread Limits

Hello,

I have the method below on my server and generally it works well.

But in times of high server usage, the response to the client takes a long time and this seems to affect the entire server.

At these times, I sometimes have up to 100 clients connected and many of them accessing the same service.

About this scenario:

Is there a maximum number of threads that can be opened on the server?

Is there a maximum connection time for executing the procedure?

Any suggestions to improve this process?

    [ROServiceMethod]
    [ROCustom('HttpApiPath','getboleto')]
    [ROCustom('HttpApiMethod','GET')]
    function getBoleto([ROCustom('HttpApiQueryParameter','1')] codempresa: Integer;
                       [ROCustom('HttpApiQueryParameter','1')] numlancamento: Integer): Binary;



function TSispetroWeb.getBoleto(codempresa, numlancamento: Integer): Binary;
var
  lStream: TMemoryStream;
  lFilename: string;
begin
  lStream := TMemoryStream.Create;
  try

    Result := TROHttpApiResult.Create(HTTP_200_code, id_ContentType_application_pdf,'',false);

    try
      GetBoletoStream(codempresa, numlancamento, lFilename, lStream, conexao);
      result.LoadFromStream(lStream);
    except
      on E: Exception do begin
        FSiSession.LogError('SispetroWeb: erro ao gerar boleto ->' + e.Message);
      end;

    end;

  finally
    FreeAndNil(lStream);
  end;
end;

Hi,

Your method (GetBoletoStream) can consume all CPU resources especially when you have 100 simultaneous connections.

What HTTP server are you using? we have 5 different HTTP servers in Delphi.

You can change default class factory with pooled one. Pooled class factory is more suitable for high performance and high load services

I’m using TRoIndyHttpServer. Is there a limit on this server? Would you recommend using another one? If yes, why?

Some example for Pooled class factory.

Thanks

Hi,

We haven’t apply any limitations for TROIndyHttpServer, but they may be on Indy level.

You can try to use TROHttpServer - it may show better performance. it is based on Microsoft HTTP Server API. You can set up number of threads via TROHTTPServer.ThreadPool property.

Check Class Factories sample (Delphi)

Hi,

I have a 6th HTTP Server implementation based on RealThinClientSDK which now it’s open source. The source might needs some more polishing but it works for me, for more than a year and a half this DAServer is the back-end of our company’s website.

I also create a new descendant of TROClassFactory, an ROClassFactory based on this idea:

If anyone is interested I can share the code.

Chris