curl-users
Delay in HTTP PUT and a SOLUTION
Date: Wed, 17 Sep 2008 15:19:38 +1000 (EST)
Hello,
I found that curl GET POST and DELETE worked at a fairly high rate 30+
requests per second, but PUT took about 1 second longer for each request,
very slow indeed. The environment is listed below.
Here is the command used for POST:
curl -v -H 'Content-Type: application/xml; charset=utf-8' --data-ascii
\@tst.xml http://127.0.0.1:8000/xml/book/3
and for PUT:
curl -v -H 'Content-Type: application/xml; charset=utf-8' -T tst.xml
http://127.0.0.1:8000/xml/book/3
Analysis of the messages using tshark showed that curl was splitting up
the message sent, with 1 second delay on the curl side. The second part of
the message was the file contents, 289 bytes in this case. Trace is
appended.
SOLUTION/WORKAROUND:
By using "-T -" and taking the input from standard in instead of a file,
the data was sent out in one TCP message of about 500 bytes, and the
performance problem went away. Now get 33 requests/second, same as POST.
PUT command line that worked fine:
cat tst.xml | curl -v -H 'Content-Type: application/xml; charset=utf-8' -T
- http://127.0.0.1:8000/xml/book/3
It would be nice to know why the delay is introduced when PUT'ing from a
file but not when POST'ing from a file, but it is not very important
because there is a workaround.
The tshark trace:
0.000000 127.0.0.1 -> 127.0.0.1 TCP 37826 > irdmi [SYN] Seq=0
Win=32792 Len=0 MSS=16396 TSV=27384666 TSER=0 WS=6
0.000012 127.0.0.1 -> 127.0.0.1 TCP irdmi > 37826 [SYN, ACK] Seq=0
Ack=1 Win=32768 Len=0 MSS=16396 TSV=27384666 TSER=27384666 WS=6
0.000021 127.0.0.1 -> 127.0.0.1 TCP 37826 > irdmi [ACK] Seq=1
Ack=1 Win=32832 Len=0 TSV=27384666 TSER=27384666
0.000682 127.0.0.1 -> 127.0.0.1 TCP 37826 > irdmi [PSH, ACK] Seq=1
Ack=1 Win=32832 [TCP CHECKSUM INCORRECT] Len=251 TSV=27384666
TSER=27384666
0.000728 127.0.0.1 -> 127.0.0.1 TCP irdmi > 37826 [ACK] Seq=1
Ack=252 Win=33856 Len=0 TSV=27384666 TSER=27384666
1.019649 127.0.0.1 -> 127.0.0.1 TCP 37826 > irdmi [PSH, ACK]
Seq=252 Ack=1 Win=32832 [TCP CHECKSUM INCORRECT] Len=289 TSV=27384921
TSER=27384666
Environment: single thread client (script calling curl in a loop), slow
laptop computer, ubuntu 8.04 OS, django server on the same machine as
client
curl 7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0
Rodney, Australia
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-09-17