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;
EvgenyK
(Evgeny Karpov)
November 28, 2023, 6:31am
2
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
EvgenyK:
Pooled class factory
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
EvgenyK
(Evgeny Karpov)
November 28, 2023, 11:29am
4
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)
chrisroyal
(chrisroyal)
November 29, 2023, 7:14am
5
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:
Work and processing classes are typically short-lived, created to perform one form of processing or another then freed. They can be simple collections, handle I/O of one kind of another, perform computations, pattern matching, etc. When they're used...
Work and processing classes are typically short-lived, created to perform one form of processing or another then freed. They can be simple collections, handle I/O of one kind of another, perform computations, pattern matching, etc. When they're used...
If anyone is interested I can share the code.
Chris