Multiple pipelines and limiting the number of connections.

Introducing a number of options to the multi interface that
allows for multiple pipelines to the same host, in order to
optimize the balance between the penalty for opening new
connections and the potential pipelining latency.

Two new options for limiting the number of connections:

CURLMOPT_MAX_HOST_CONNECTIONS - Limits the number of running connections
to the same host. When adding a handle that exceeds this limit,
that handle will be put in a pending state until another handle is
finished, so we can reuse the connection.

CURLMOPT_MAX_TOTAL_CONNECTIONS - Limits the number of connections in total.
When adding a handle that exceeds this limit,
that handle will be put in a pending state until another handle is
finished. The free connection will then be reused, if possible, or
closed if the pending handle can't reuse it.

Several new options for pipelining:

CURLMOPT_MAX_PIPELINE_LENGTH - Limits the pipeling length. If a
pipeline is "full" when a connection is to be reused, a new connection
will be opened if the CURLMOPT_MAX_xxx_CONNECTIONS limits allow it.
If not, the handle will be put in a pending state until a connection is
ready (either free or a pipe got shorter).

CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE - A pipelined connection will not
be reused if it is currently processing a transfer with a content
length that is larger than this.

CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE - A pipelined connection will not
be reused if it is currently processing a chunk larger than this.

CURLMOPT_PIPELINING_SITE_BL - A blacklist of hosts that don't allow
pipelining.

CURLMOPT_PIPELINING_SERVER_BL - A blacklist of server types that don't allow
pipelining.

See the curl_multi_setopt() man page for details.
This commit is contained in:
Linus Nielsen Feltzing
2013-02-15 11:50:45 +01:00
parent 911b2d3f67
commit 0f147887b0
37 changed files with 2210 additions and 279 deletions

View File

@@ -95,13 +95,14 @@ test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
test1408 test1409 test1410 test1411 test1412 test1413 \
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 \
test1900 test1901 test1902 test1903 \
test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \
test2016 test2017 test2018 test2019 test2020 test2021 test2022 \
test2023 test2024 test2025 \
test2026 test2027 test2028 \
test2029 test2030 test2031 \
test2032
test2032 test2033
EXTRA_DIST = $(TESTCASES) DISABLED

57
tests/data/test1900 Normal file
View File

@@ -0,0 +1,57 @@
<testcase>
<info>
<keywords>
HTTP
pipelining
multi
</keywords>
</info>
# Server-side
<reply>
<data>
Adding handle 0
Handle 0 Completed with status 0
Adding handle 1
Adding handle 2
Adding handle 3
Adding handle 4
Adding handle 5
Adding handle 6
Handle 4 Completed with status 0
Handle 5 Completed with status 0
Handle 6 Completed with status 0
Handle 1 Completed with status 0
Handle 2 Completed with status 0
Handle 3 Completed with status 0
</data>
</reply>
# Client-side
<client>
<server>
http-pipe
</server>
<tool>
lib1900
</tool>
<name>
HTTP GET using pipelining
</name>
<command>
http://%HOSTIP:%HTTPPIPEPORT/
</command>
<file name="log/urls.txt">
0 1k.txt
1000 100k.txt
0 1k.txt
0 1k.txt
0 1k.txt
0 1k.txt
0 1k.txt
</client>
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>

58
tests/data/test1901 Normal file
View File

@@ -0,0 +1,58 @@
<testcase>
<info>
<keywords>
HTTP
pipelining
multi
</keywords>
</info>
# Server-side
<reply>
<data>
Adding handle 0
Handle 0 Completed with status 0
Adding handle 1
Adding handle 2
Adding handle 3
Adding handle 4
Adding handle 5
Adding handle 6
Handle 2 Completed with status 0
Handle 3 Completed with status 0
Handle 4 Completed with status 0
Handle 1 Completed with status 0
Handle 5 Completed with status 0
Handle 6 Completed with status 0
</data>
</reply>
# Client-side
<client>
<server>
http-pipe
</server>
<tool>
lib1900
</tool>
<name>
HTTP GET using pipelining, blacklisted site
</name>
<command>
http://%HOSTIP:%HTTPPIPEPORT/
</command>
<file name="log/urls.txt">
blacklist_site 127.0.0.1:%HTTPPIPEPORT
0 1k.txt
1000 100k.txt
0 1k.txt
0 1k.txt
0 1k.txt
0 1k.txt
0 1k.txt
</client>
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>

57
tests/data/test1902 Normal file
View File

@@ -0,0 +1,57 @@
<testcase>
<info>
<keywords>
HTTP
pipelining
multi
</keywords>
</info>
# Server-side
<reply>
<data>
Adding handle 0
Handle 0 Completed with status 0
Adding handle 1
Adding handle 2
Adding handle 3
Adding handle 4
Adding handle 5
Adding handle 6
Handle 1 Completed with status 0
Handle 4 Completed with status 0
Handle 5 Completed with status 0
Handle 6 Completed with status 0
Handle 2 Completed with status 0
Handle 3 Completed with status 0
</data>
</reply>
# Client-side
<client>
<server>
http-pipe
</server>
<tool>
lib1900
</tool>
<name>
HTTP GET using pipelining, broken pipe
</name>
<command>
http://%HOSTIP:%HTTPPIPEPORT/
</command>
<file name="log/urls.txt">
0 1k.txt
1000 connection_close.txt
0 1k.txt
0 1k.txt
0 1k.txt
0 1k.txt
0 1k.txt
</client>
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>

57
tests/data/test1903 Normal file
View File

@@ -0,0 +1,57 @@
<testcase>
<info>
<keywords>
HTTP
pipelining
multi
</keywords>
</info>
# Server-side
<reply>
<data>
Adding handle 0
Handle 0 Completed with status 0
Adding handle 1
Adding handle 2
Adding handle 3
Adding handle 4
Adding handle 5
Adding handle 6
Handle 2 Completed with status 0
Handle 3 Completed with status 0
Handle 4 Completed with status 0
Handle 5 Completed with status 0
Handle 6 Completed with status 0
Handle 1 Completed with status 0
</data>
</reply>
# Client-side
<client>
<server>
http-pipe
</server>
<tool>
lib1900
</tool>
<name>
HTTP GET using pipelining, penalized on content-length
</name>
<command>
http://%HOSTIP:%HTTPPIPEPORT/
</command>
<file name="log/urls.txt">
0 1k.txt
1000 100k.txt
550 alphabet.txt
10 alphabet.txt
10 alphabet.txt
10 alphabet.txt
10 alphabet.txt
</client>
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>

144
tests/data/test2033 Normal file
View File

@@ -0,0 +1,144 @@
<testcase>
<info>
<keywords>
HTTP
HTTP GET
HTTP Basic auth
HTTP NTLM auth
pipelining
</keywords>
</info>
# Server-side
<reply>
<!-- Basic auth -->
<data100>
HTTP/1.1 401 Need Basic or NTLM auth
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 29
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="testrealm"
This is a bad password page!
</data100>
<!-- NTML auth -->
<data200>
HTTP/1.1 401 Need Basic or NTLM auth (2)
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 27
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="testrealm"
This is not the real page!
</data200>
<data1201>
HTTP/1.1 401 NTLM intermediate (2)
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 33
WWW-Authenticate: NTLM TlRMTVNTUAACAAAACAAIADAAAAAGggEAq6U1NAWaJCIAAAAAAAAAAAAAAAA4AAAATlRMTUF1dGg=
This is still not the real page!
</data1201>
<data1202>
HTTP/1.1 200 Things are fine in server land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 32
Finally, this is the real page!
</data1202>
<datacheck>
HTTP/1.1 401 Need Basic or NTLM auth
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 29
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="testrealm"
This is a bad password page!
HTTP/1.1 401 Need Basic or NTLM auth
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 29
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="testrealm"
This is a bad password page!
HTTP/1.1 401 NTLM intermediate (2)
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 33
WWW-Authenticate: NTLM TlRMTVNTUAACAAAACAAIADAAAAAGggEAq6U1NAWaJCIAAAAAAAAAAAAAAAA4AAAATlRMTUF1dGg=
HTTP/1.1 200 Things are fine in server land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
Content-Length: 32
Finally, this is the real page!
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
<tool>
lib2033
</tool>
<name>
NTLM connection mapping, pipelining enabled
</name>
<setenv>
# we force our own host name, in order to make the test machine independent
CURL_GETHOSTNAME=curlhost
# we try to use the LD_PRELOAD hack, if not a debug build
LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
</setenv>
<command>
http://%HOSTIP:%HTTPPORT/2032
</command>
<precheck>
chkhostname curlhost
</precheck>
</client>
# Verify data after the test has been "shot"
<verify>
<strip>
^User-Agent:.*
</strip>
<protocol>
GET /20320100 HTTP/1.1
Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=
Host: 127.0.0.1:8990
Accept: */*
GET /20320100 HTTP/1.1
Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=
Host: 127.0.0.1:8990
Accept: */*
GET /20320200 HTTP/1.1
Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Host: 127.0.0.1:8990
Accept: */*
GET /20320200 HTTP/1.1
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoIBAI+/Fp9IERAQ74OsdNPbBpg7o8CVwLSO4DtFyIcZHUMKVktWIu92s2892OVpd2JzqnRlc3R1c2VyY3VybGhvc3Q=
Host: 127.0.0.1:8990
Accept: */*
</protocol>
</verify>
</testcase>

View File

@@ -2,7 +2,7 @@
<info>
<keywords>
HTTP
Pipelining
pipelining
multi
</keywords>
</info>

View File

@@ -1,4 +1,12 @@
<testcase>
<info>
<keywords>
HTTP
pipelining
multi
</keywords>
</info>
<reply>
<data mode="text">
HTTP/1.1 404 Badness

View File

@@ -2,7 +2,7 @@
<info>
<keywords>
HTTP
Pipelining
pipelining
multi
</keywords>
</info>