Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
439dbce6
Commit
439dbce6
authored
Jan 14, 2019
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nghttpx-h1-connection-pool-per-addr'
parents
803d4ba9
e9c9838c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
53 deletions
+37
-53
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+35
-32
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+0
-10
src/shrpx_worker.cc
src/shrpx_worker.cc
+2
-10
src/shrpx_worker.h
src/shrpx_worker.h
+0
-1
No files found.
src/shrpx_client_handler.cc
View file @
439dbce6
...
...
@@ -658,30 +658,11 @@ void ClientHandler::pool_downstream_connection(
<<
" in group "
<<
group
;
}
auto
&
shared_addr
=
group
->
shared_addr
;
if
(
shared_addr
->
affinity
.
type
==
SessionAffinity
::
NONE
)
{
auto
&
dconn_pool
=
group
->
shared_addr
->
dconn_pool
;
dconn_pool
.
add_downstream_connection
(
std
::
move
(
dconn
));
return
;
}
auto
addr
=
dconn
->
get_addr
();
auto
&
dconn_pool
=
addr
->
dconn_pool
;
dconn_pool
->
add_downstream_connection
(
std
::
move
(
dconn
));
}
void
ClientHandler
::
remove_downstream_connection
(
DownstreamConnection
*
dconn
)
{
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Removing downstream connection DCONN:"
<<
dconn
<<
" from pool"
;
}
auto
&
dconn_pool
=
dconn
->
get_downstream_addr_group
()
->
shared_addr
->
dconn_pool
;
dconn_pool
.
remove_downstream_connection
(
dconn
);
}
namespace
{
// Computes 32bits hash for session affinity for IP address |ip|.
uint32_t
compute_affinity_from_ip
(
const
StringRef
&
ip
)
{
...
...
@@ -1138,26 +1119,48 @@ ClientHandler::get_downstream_connection(int &err, Downstream *downstream,
return
std
::
move
(
dconn
);
}
auto
&
dconn_pool
=
shared_addr
->
dconn_pool
;
auto
end
=
shared_addr
->
next
;
for
(;;)
{
auto
addr
=
&
shared_addr
->
addrs
[
shared_addr
->
next
];
if
(
addr
->
proto
!=
Proto
::
HTTP1
)
{
if
(
++
shared_addr
->
next
>=
shared_addr
->
addrs
.
size
())
{
shared_addr
->
next
=
0
;
}
// pool connection must be HTTP/1.1 connection
auto
dconn
=
dconn_pool
.
pop_downstream_connection
();
assert
(
end
!=
shared_addr
->
next
);
if
(
dconn
)
{
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Reuse downstream connection DCONN:"
<<
dconn
.
get
()
<<
" from pool"
;
continue
;
}
}
else
{
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Downstream connection pool is empty."
<<
" Create new one"
;
// pool connection must be HTTP/1.1 connection
auto
dconn
=
addr
->
dconn_pool
->
pop_downstream_connection
();
if
(
dconn
)
{
if
(
++
shared_addr
->
next
>=
shared_addr
->
addrs
.
size
())
{
shared_addr
->
next
=
0
;
}
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Reuse downstream connection DCONN:"
<<
dconn
.
get
()
<<
" from pool"
;
}
dconn
->
set_client_handler
(
this
);
return
dconn
;
}
dconn
=
std
::
make_unique
<
HttpDownstreamConnection
>
(
group
,
0
,
conn_
.
loop
,
worker_
);
break
;
}
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Downstream connection pool is empty."
<<
" Create new one"
;
}
auto
dconn
=
std
::
make_unique
<
HttpDownstreamConnection
>
(
group
,
0
,
conn_
.
loop
,
worker_
);
dconn
->
set_client_handler
(
this
);
return
dconn
;
...
...
src/shrpx_http_downstream_connection.cc
View file @
439dbce6
...
...
@@ -807,16 +807,6 @@ int HttpDownstreamConnection::end_upload_data() {
namespace
{
void
remove_from_pool
(
HttpDownstreamConnection
*
dconn
)
{
auto
&
group
=
dconn
->
get_downstream_addr_group
();
auto
&
shared_addr
=
group
->
shared_addr
;
if
(
shared_addr
->
affinity
.
type
==
SessionAffinity
::
NONE
)
{
auto
&
dconn_pool
=
dconn
->
get_downstream_addr_group
()
->
shared_addr
->
dconn_pool
;
dconn_pool
.
remove_downstream_connection
(
dconn
);
return
;
}
auto
addr
=
dconn
->
get_addr
();
auto
&
dconn_pool
=
addr
->
dconn_pool
;
dconn_pool
->
remove_downstream_connection
(
dconn
);
...
...
src/shrpx_worker.cc
View file @
439dbce6
...
...
@@ -164,12 +164,6 @@ void Worker::replace_downstream_config(
g
->
retired
=
true
;
auto
&
shared_addr
=
g
->
shared_addr
;
if
(
shared_addr
->
affinity
.
type
==
SessionAffinity
::
NONE
)
{
shared_addr
->
dconn_pool
.
remove_all
();
continue
;
}
for
(
auto
&
addr
:
shared_addr
->
addrs
)
{
addr
.
dconn_pool
->
remove_all
();
}
...
...
@@ -307,10 +301,8 @@ void Worker::replace_downstream_config(
std
::
shuffle
(
std
::
begin
(
shared_addr
->
addrs
),
std
::
end
(
shared_addr
->
addrs
),
randgen_
);
if
(
shared_addr
->
affinity
.
type
!=
SessionAffinity
::
NONE
)
{
for
(
auto
&
addr
:
shared_addr
->
addrs
)
{
addr
.
dconn_pool
=
std
::
make_unique
<
DownstreamConnectionPool
>
();
}
for
(
auto
&
addr
:
shared_addr
->
addrs
)
{
addr
.
dconn_pool
=
std
::
make_unique
<
DownstreamConnectionPool
>
();
}
dst
->
shared_addr
=
shared_addr
;
...
...
src/shrpx_worker.h
View file @
439dbce6
...
...
@@ -164,7 +164,6 @@ struct SharedDownstreamAddr {
// TODO Verify that this approach performs better in performance
// wise.
DList
<
Http2Session
>
http2_avail_freelist
;
DownstreamConnectionPool
dconn_pool
;
// Configuration for session affinity
AffinityConfig
affinity
;
// Next http/1.1 downstream address index in addrs.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment