Remove max session limit from relayd

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Remove max session limit from relayd

Claudio Jeker
Relayd has a limit of 1024 session per relay process. This is not enough
on busy web proxies with decent keep-alive usage. Once the limit is
reached new sessions are just dropped with makes the situation worse.
Since relayd already handles out of file descriptor situation more
gracefully I see no need to keep this artifical limit around.

The following diff removes RELAY_MAX_SESSIONS, OK?
--
:wq Claudio

Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/parse.y,v
retrieving revision 1.221
diff -u -p -r1.221 parse.y
--- parse.y 29 Nov 2017 15:24:50 -0000 1.221
+++ parse.y 15 Apr 2018 11:29:18 -0000
@@ -1081,7 +1081,7 @@ tcpflags : SACK { proto->tcpflags |= T
  | SPLICE { /* default */ }
  | NO SPLICE { proto->tcpflags |= TCPFLAG_NSPLICE; }
  | BACKLOG NUMBER {
- if ($2 < 0 || $2 > RELAY_MAX_SESSIONS) {
+ if ($2 < 0 || $2 > 512) {
  yyerror("invalid backlog: %d", $2);
  YYERROR;
  }
Index: relay.c
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/relay.c,v
retrieving revision 1.237
diff -u -p -r1.237 relay.c
--- relay.c 27 Dec 2017 15:53:30 -0000 1.237
+++ relay.c 15 Apr 2018 11:29:18 -0000
@@ -1077,8 +1077,7 @@ relay_accept(int fd, short event, void *
  }
  return;
  }
- if (relay_sessions >= RELAY_MAX_SESSIONS ||
-    rlay->rl_conf.flags & F_DISABLE)
+ if (rlay->rl_conf.flags & F_DISABLE)
  goto err;
 
  if ((con = calloc(1, sizeof(*con))) == NULL)
Index: relay_udp.c
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/relay_udp.c,v
retrieving revision 1.47
diff -u -p -r1.47 relay_udp.c
--- relay_udp.c 4 Jul 2017 19:59:51 -0000 1.47
+++ relay_udp.c 15 Apr 2018 11:29:19 -0000
@@ -191,8 +191,7 @@ relay_udp_response(int fd, short sig, vo
  return;
  }
 
- if (relay_sessions >= RELAY_MAX_SESSIONS ||
-    rlay->rl_conf.flags & F_DISABLE)
+ if (rlay->rl_conf.flags & F_DISABLE)
  return;
 
  slen = sizeof(ss);
@@ -226,8 +225,7 @@ relay_udp_server(int fd, short sig, void
 
  event_add(&rlay->rl_ev, NULL);
 
- if (relay_sessions >= RELAY_MAX_SESSIONS ||
-    rlay->rl_conf.flags & F_DISABLE)
+ if (rlay->rl_conf.flags & F_DISABLE)
  return;
 
  slen = sizeof(ss);
Index: relayd.h
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/relayd.h,v
retrieving revision 1.248
diff -u -p -r1.248 relayd.h
--- relayd.h 28 Nov 2017 18:25:53 -0000 1.248
+++ relayd.h 15 Apr 2018 11:29:19 -0000
@@ -68,7 +68,6 @@
 
 #define FD_RESERVE 5
 
-#define RELAY_MAX_SESSIONS 1024
 #define RELAY_TIMEOUT 600
 #define RELAY_CACHESIZE -1 /* use default size */
 #define RELAY_NUMPROC 3

Reply | Threaded
Open this post in threaded view
|

Re: Remove max session limit from relayd

Sebastian Benoit-3
Claudio Jeker([hidden email]) on 2018.04.15 13:36:25 +0200:

> Relayd has a limit of 1024 session per relay process. This is not enough
> on busy web proxies with decent keep-alive usage. Once the limit is
> reached new sessions are just dropped with makes the situation worse.
> Since relayd already handles out of file descriptor situation more
> gracefully I see no need to keep this artifical limit around.
>
> The following diff removes RELAY_MAX_SESSIONS, OK?
> --
> :wq Claudio
>
> Index: parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/relayd/parse.y,v
> retrieving revision 1.221
> diff -u -p -r1.221 parse.y
> --- parse.y 29 Nov 2017 15:24:50 -0000 1.221
> +++ parse.y 15 Apr 2018 11:29:18 -0000
> @@ -1081,7 +1081,7 @@ tcpflags : SACK { proto->tcpflags |= T
>   | SPLICE { /* default */ }
>   | NO SPLICE { proto->tcpflags |= TCPFLAG_NSPLICE; }
>   | BACKLOG NUMBER {
> - if ($2 < 0 || $2 > RELAY_MAX_SESSIONS) {
> + if ($2 < 0 || $2 > 512) {

maybe use (new) RELAY_MAX_BACKLOG there instead of 512?
why 512 instead of 1024?

i think this needs mentioning in the manpage

diff --git usr.sbin/relayd/relayd.conf.5 usr.sbin/relayd/relayd.conf.5
index b6fd6530d79..bbe71739db4 100644
--- usr.sbin/relayd/relayd.conf.5
+++ usr.sbin/relayd/relayd.conf.5
@@ -849,7 +849,8 @@ Valid options are:
 .Bl -tag -width Ds
 .It Ic backlog Ar number
 Set the maximum length the queue of pending connections may grow to.
-The backlog option is 10 by default and is limited by the
+The backlog option is 10 by default, can be set to a maximum of 512
+and is limited by the
 .Ic kern.somaxconn
 .Xr sysctl 8
 variable.

with something like that ok benno@

>   yyerror("invalid backlog: %d", $2);
>   YYERROR;
>   }
> Index: relay.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/relayd/relay.c,v
> retrieving revision 1.237
> diff -u -p -r1.237 relay.c
> --- relay.c 27 Dec 2017 15:53:30 -0000 1.237
> +++ relay.c 15 Apr 2018 11:29:18 -0000
> @@ -1077,8 +1077,7 @@ relay_accept(int fd, short event, void *
>   }
>   return;
>   }
> - if (relay_sessions >= RELAY_MAX_SESSIONS ||
> -    rlay->rl_conf.flags & F_DISABLE)
> + if (rlay->rl_conf.flags & F_DISABLE)
>   goto err;
>  
>   if ((con = calloc(1, sizeof(*con))) == NULL)
> Index: relay_udp.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/relayd/relay_udp.c,v
> retrieving revision 1.47
> diff -u -p -r1.47 relay_udp.c
> --- relay_udp.c 4 Jul 2017 19:59:51 -0000 1.47
> +++ relay_udp.c 15 Apr 2018 11:29:19 -0000
> @@ -191,8 +191,7 @@ relay_udp_response(int fd, short sig, vo
>   return;
>   }
>  
> - if (relay_sessions >= RELAY_MAX_SESSIONS ||
> -    rlay->rl_conf.flags & F_DISABLE)
> + if (rlay->rl_conf.flags & F_DISABLE)
>   return;
>  
>   slen = sizeof(ss);
> @@ -226,8 +225,7 @@ relay_udp_server(int fd, short sig, void
>  
>   event_add(&rlay->rl_ev, NULL);
>  
> - if (relay_sessions >= RELAY_MAX_SESSIONS ||
> -    rlay->rl_conf.flags & F_DISABLE)
> + if (rlay->rl_conf.flags & F_DISABLE)
>   return;
>  
>   slen = sizeof(ss);
> Index: relayd.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/relayd/relayd.h,v
> retrieving revision 1.248
> diff -u -p -r1.248 relayd.h
> --- relayd.h 28 Nov 2017 18:25:53 -0000 1.248
> +++ relayd.h 15 Apr 2018 11:29:19 -0000
> @@ -68,7 +68,6 @@
>  
>  #define FD_RESERVE 5
>  
> -#define RELAY_MAX_SESSIONS 1024
>  #define RELAY_TIMEOUT 600
>  #define RELAY_CACHESIZE -1 /* use default size */
>  #define RELAY_NUMPROC 3
>

Reply | Threaded
Open this post in threaded view
|

Re: Remove max session limit from relayd

Claudio Jeker
On Sun, Apr 15, 2018 at 10:25:36PM +0200, Sebastian Benoit wrote:

> Claudio Jeker([hidden email]) on 2018.04.15 13:36:25 +0200:
> > Relayd has a limit of 1024 session per relay process. This is not enough
> > on busy web proxies with decent keep-alive usage. Once the limit is
> > reached new sessions are just dropped with makes the situation worse.
> > Since relayd already handles out of file descriptor situation more
> > gracefully I see no need to keep this artifical limit around.
> >
> > The following diff removes RELAY_MAX_SESSIONS, OK?
> > --
> > :wq Claudio
> >
> > Index: parse.y
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/relayd/parse.y,v
> > retrieving revision 1.221
> > diff -u -p -r1.221 parse.y
> > --- parse.y 29 Nov 2017 15:24:50 -0000 1.221
> > +++ parse.y 15 Apr 2018 11:29:18 -0000
> > @@ -1081,7 +1081,7 @@ tcpflags : SACK { proto->tcpflags |= T
> >   | SPLICE { /* default */ }
> >   | NO SPLICE { proto->tcpflags |= TCPFLAG_NSPLICE; }
> >   | BACKLOG NUMBER {
> > - if ($2 < 0 || $2 > RELAY_MAX_SESSIONS) {
> > + if ($2 < 0 || $2 > 512) {
>
> maybe use (new) RELAY_MAX_BACKLOG there instead of 512?
> why 512 instead of 1024?

Mainly because the listen backlog is limited by the kernel to 128 by
default and needs a tunable to change that. Also having 512 tcp sessions
in the backlog is probably good enough. I can throw in a define for that.
 

> i think this needs mentioning in the manpage
>
> diff --git usr.sbin/relayd/relayd.conf.5 usr.sbin/relayd/relayd.conf.5
> index b6fd6530d79..bbe71739db4 100644
> --- usr.sbin/relayd/relayd.conf.5
> +++ usr.sbin/relayd/relayd.conf.5
> @@ -849,7 +849,8 @@ Valid options are:
>  .Bl -tag -width Ds
>  .It Ic backlog Ar number
>  Set the maximum length the queue of pending connections may grow to.
> -The backlog option is 10 by default and is limited by the
> +The backlog option is 10 by default, can be set to a maximum of 512
> +and is limited by the
>  .Ic kern.somaxconn
>  .Xr sysctl 8
>  variable.
>
> with something like that ok benno@

I can add this to the diff.

>
> >   yyerror("invalid backlog: %d", $2);
> >   YYERROR;
> >   }
> > Index: relay.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/relayd/relay.c,v
> > retrieving revision 1.237
> > diff -u -p -r1.237 relay.c
> > --- relay.c 27 Dec 2017 15:53:30 -0000 1.237
> > +++ relay.c 15 Apr 2018 11:29:18 -0000
> > @@ -1077,8 +1077,7 @@ relay_accept(int fd, short event, void *
> >   }
> >   return;
> >   }
> > - if (relay_sessions >= RELAY_MAX_SESSIONS ||
> > -    rlay->rl_conf.flags & F_DISABLE)
> > + if (rlay->rl_conf.flags & F_DISABLE)
> >   goto err;
> >  
> >   if ((con = calloc(1, sizeof(*con))) == NULL)
> > Index: relay_udp.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/relayd/relay_udp.c,v
> > retrieving revision 1.47
> > diff -u -p -r1.47 relay_udp.c
> > --- relay_udp.c 4 Jul 2017 19:59:51 -0000 1.47
> > +++ relay_udp.c 15 Apr 2018 11:29:19 -0000
> > @@ -191,8 +191,7 @@ relay_udp_response(int fd, short sig, vo
> >   return;
> >   }
> >  
> > - if (relay_sessions >= RELAY_MAX_SESSIONS ||
> > -    rlay->rl_conf.flags & F_DISABLE)
> > + if (rlay->rl_conf.flags & F_DISABLE)
> >   return;
> >  
> >   slen = sizeof(ss);
> > @@ -226,8 +225,7 @@ relay_udp_server(int fd, short sig, void
> >  
> >   event_add(&rlay->rl_ev, NULL);
> >  
> > - if (relay_sessions >= RELAY_MAX_SESSIONS ||
> > -    rlay->rl_conf.flags & F_DISABLE)
> > + if (rlay->rl_conf.flags & F_DISABLE)
> >   return;
> >  
> >   slen = sizeof(ss);
> > Index: relayd.h
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/relayd/relayd.h,v
> > retrieving revision 1.248
> > diff -u -p -r1.248 relayd.h
> > --- relayd.h 28 Nov 2017 18:25:53 -0000 1.248
> > +++ relayd.h 15 Apr 2018 11:29:19 -0000
> > @@ -68,7 +68,6 @@
> >  
> >  #define FD_RESERVE 5
> >  
> > -#define RELAY_MAX_SESSIONS 1024
> >  #define RELAY_TIMEOUT 600
> >  #define RELAY_CACHESIZE -1 /* use default size */
> >  #define RELAY_NUMPROC 3
> >
>

--
:wq Claudio