Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wsgi: Disable Nagle algorithm on client side
When sending a PUT request, the http header may be sent in the first packet when calling con.endheaders(). When we send the first chunk, the kernel may delay the send because the header packet was not acked yet. We have seen PUT requests delayed by 40 milliseconds on the server side. Typically the server receive the header, and then wait about 40 milliseconds for the message body. The actual work for such request may take less then a millisecond. This issue was fixed in python 3.5 by using the TCP_NO_DELAY option after connecting[1]. I backported this change from python 3.5. Here is example upload before this change: $ time ./upload RHEL7_1-001.raw https://host:54322/images/test real 3m42.144s user 0m16.240s sys 0m5.515s OPTIONS /images/test: [200] 74 [request=0.000859] PUT /images/test: [200] 0 [request=0.040728, operation=0.039781, read=0.038662, write=0.000838] PATCH /images/test: [200] 0 [request=0.003775, operation=0.003051, write=0.002775] The server wait 38 milliseconds for a tiny payload written in 838 microseconds. Here is the same upload after this change: $ time ./upload RHEL7_1-001.raw https://host:54322/images/test real 1m2.492s user 0m16.232s sys 0m5.619s OPTIONS /images/test: [200] 74 [request=0.000972] PUT /images/test: [200] 0 [request=0.002804, operation=0.001437, read=0.000149, write=0.000841] PATCH /images/test: [200] 0 [request=0.003511, operation=0.002860, write=0.002646] Now the server read the payload in 149 microseconds instead of 38 milliseconds, and the entire request was completed in 2.8 milliseconds instead of 40 milliseconds. [1] https://bugs.python.org/issue23302 Change-Id: Iebbbceafa0aff5c363e281758daace551f8da8f6 Signed-off-by: Nir Soffer <nsoffer@redhat.com>
- Loading branch information