-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conf, router: Make the listen(2) backlog configurable #1388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the prefix can be removed from the commit subject, "conf, router" is a bit strange.
src/nxt_router.c
Outdated
int listen_backlog = -1; | ||
nxt_conf_value_t *backlog; | ||
|
||
static const nxt_str_t backlog_path = nxt_string("backlog"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ac000,
What about moving it into nxt_router_listener_conf
?
For example:
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 43209451..fe4bbabc 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -1964,13 +1964,10 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
break;
}
- skcf = nxt_router_socket_conf(task, tmcf, &name);
- if (skcf == NULL) {
- goto fail;
- }
-
nxt_memzero(&lscf, sizeof(lscf));
+ lscf.backlog = -1;
+
ret = nxt_conf_map_object(mp, listener, nxt_router_listener_conf,
nxt_nitems(nxt_router_listener_conf),
&lscf);
@@ -1981,6 +1978,13 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
nxt_debug(task, "application: %V", &lscf.applicatio
n);
+ /* use lscf.backlog */
+
+ skcf = nxt_router_socket_conf(task, tmcf, &name);
+ if (skcf == NULL) {
+ goto fail;
+ }
+
// STUB, default values if http block is not define
d.
I usually prefer to get object property by nxt_conf_map_object()
rather than explicitly nxt_conf_get_object_member()
.
Others look good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try that originally but then it started getting messy... let me take another look...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so it means
-
Adding a new 'backlog' entry to nxt_router_listener_conf[]
-
Adding a new 'backlog' member to nxt_router_listener_conf_t
-
Adding a pointer to nxt_router_listener_conf_t in nxt_router_temp_conf_t
So I took the simpler route, but sure, I can do the above instead...
It's simply because sometimes a change effects multiple areas, e.g
In this case it adds a new config option that effects the router. If I removed it, I would need to change the subject as well as this change only effects the routers listen sockets... |
c6d5699
to
fbf15bd
Compare
This meant the following needed to be done
That last one required moving the nxt_router_listener_conf_t structure definition into src/nxt_router.h It's a bit of mess due to all the variable re-alignment required (but that's a result of how we do our variable declarations...) I will likely split this up into several patches once we're happy with the actual code...
|
@@ -1494,6 +1489,12 @@ static nxt_conf_map_t nxt_router_listener_conf[] = { | |||
NXT_CONF_MAP_STR_COPY, | |||
offsetof(nxt_router_listener_conf_t, application), | |||
}, | |||
|
|||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I mean.
src/nxt_router.c
Outdated
@@ -1981,6 +1979,13 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, | |||
|
|||
nxt_debug(task, "application: %V", &lscf.application); | |||
|
|||
tmcf->listener_conf = &lscf; | |||
|
|||
skcf = nxt_router_socket_conf(task, tmcf, &name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like your previous way is better, could you try it again?
nxt_router_socket_conf(task, tmcf, &name, lscf.backlog);
That we don't need to add listener_conf
to tmcf
.
I guess it's more concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, a mixture of the original and this way, yeah, that maybe makes sense.
fbf15bd
to
c6d5699
Compare
This basically just reverts the last change to make the next change much clearer... |
c6d5699
to
4f99b04
Compare
|
4f99b04
to
9c7c57c
Compare
Update the commit regarding the commit that changed the default listen backlog on Linux.
|
@oopsoop2 on GitHub reported a performance issue related to the default listen(2) backlog size of 511 on nginx. They found that increasing it helped, nginx has a config option to configure this. They would like to be able to do the same on Unit (which also defaults to 511 on some systems). This seems reasonable. NOTE: On Linux before commit 97c15fa ("socket: Use a default listen backlog of -1 on Linux") we defaulted to 511. Since that commit we default to the Kernels default, which before 5.4 is 128 and after is 4096. This adds a new per-listener 'backlog' config option, e.g { "listeners": { "[::1]:8080": { "pass": "routes", "backlog": 1024 }, } ... } This doesn't effect the control socket. Closes: nginx#1384 Reported-by: <https://github.com/oopsoop2> Signed-off-by: Andrew Clayton <[email protected]>
9c7c57c
to
76489fb
Compare
Rebased with master |
@oopsoop2 on GitHub reported a performance issue related to the default listen(2) backlog size of 511 on nginx. They found that increasing it helped, nginx has a config option to configure this.
They would like to be able to do the same on Unit (which also defaults to 511 on some systems, incl Linux). This seems reasonable.
This adds a new per-listener 'backlog' config option, e.g
This doesn't effect the control socket.