Board index » delphi » Delay in TidHttp.Post when using request stream

Delay in TidHttp.Post when using request stream


2008-03-17 11:46:13 PM
delphi181
I have some strange delay when using post stream, it is not big, around
120-200 ms for one request, but I have many requests. I kinda "solved" this
problem using http headers for sending request data, but I'd really
like to know what is exactly happening. it is important to mention that this
delay happens only if client/server programs runs on *different* machines.
Here is the little demonstration program, client side, when DoPost function
is called with True, post takes 1-2 ms, when AEmptyRqStream parameter of
DoPost function is false, and 4 bytes are written in request stream, post
takes 120-200 ms !!
procedure TForm1.DoPost(AEmptyRqStream: boolean);
var
rqStream: TMemoryStream;
data: integer;
timed: int64;
begin
rqStream := nil;
rqStream := TMemoryStream.Create;
if not AEmptyRqStream then begin
data := 42;
rqStream.Write(data, SizeOf(data));
end;
rqStream.Position := 0;
timed := Miliseconds;
FHttp.Post('192.168.1.16/test', rqStream, nil);
timed := Miliseconds - timed;
lbTime.Caption := 'Time: '+IntToStr(timed) + 'ms';
FreeAndNil(rqStream);
end;
on server side i just create TIdHTTPServer and assign empty OnCommandGet
event and activate server.
btw. I tried set Nagle to false, nothing changes, and I tried Indy 9 and
Indy 10
I uploaded small example project
www.savefile.com/files/1445455
--
www.antoniob.com/
 
 

Re:Delay in TidHttp.Post when using request stream

"Antonio Bakula" <XXXX@XXXXX.COM>writes
Quote
Here is the little demonstration program, client side, when
DoPost function is called with True, post takes 1-2 ms, when
AEmptyRqStream parameter of DoPost function is false, and
4 bytes are written in request stream, post takes 120-200 ms !!
Based on the limited information you have provided, it is also hard to know
whether the delay is actualy on the client side or if it is coming from
server side. One thing I will say is that the server does have extra
processing to do before it can trigger the OnCommandGet event when you send
a content stream from the client, so you could just be seeing normal
operational overhead due to that.
Gambit
 

Re:Delay in TidHttp.Post when using request stream

On Mon, 17 Mar 2008 10:13:50 -0700, Remy Lebeau (TeamB) writes:
Quote
>Here is the little demonstration program, client side, when
>DoPost function is called with True, post takes 1-2 ms, when
>AEmptyRqStream parameter of DoPost function is false, and
>4 bytes are written in request stream, post takes 120-200 ms !!

Based on the limited information you have provided, it is also hard to know
whether the delay is actualy on the client side or if it is coming from
server side. One thing I will say is that the server does have extra
processing to do before it can trigger the OnCommandGet event when you send
a content stream from the client, so you could just be seeing normal
operational overhead due to that.

It seems that Nagle's algorithm is the reason for delay in LAN. It was a
first suspect from the begining but I was setting UseNagle property *after*
it was used by Indy to set socket properties, or something similar I don't
remember but I was using it wrong way.
Now I set UseNagle in OnConnect event handler of TidHttp and that does the
trick, is this a proper way to set UseNagle property ?
--
www.antoniob.com/