Skip to content

Commit

Permalink
add config setting for acceptor pool size
Browse files Browse the repository at this point in the history
Add new config setting to allow the size of the acceptor process pool
to be set to something other than the default. The default size is the
same as what it was prior to this change. Also add documentation for
the new setting, and augment the yaws.conf.template with information
about it.
  • Loading branch information
vinoski committed Sep 26, 2011
1 parent 914a52f commit 028f2f0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
6 changes: 6 additions & 0 deletions doc/yaws.tex
Expand Up @@ -2149,6 +2149,12 @@ \section{Global Part}
proplist may also be empty. See
\verb+erlang:spawn_opt/4+ for details on these options.

\item \verb+acceptor_pool_size = Integer+
Set the size of the pool of cached acceptor
processes. The specified value must be greater than or
equal to 0. The default value is 8. Specifying a value
of 0 effectively disables the process pool.

\end{itemize}


Expand Down
17 changes: 9 additions & 8 deletions include/yaws.hrl
Expand Up @@ -87,14 +87,15 @@
% ips we will replace with the last element
% of the list in the X-Forwarded-For http
% header in logs
yaws, %% server string
id = "default", %% string identifying this instance of yaws
enable_soap = false, %% start yaws_soap_srv iff true
soap_srv_mods = [], %% a list of
%% {{Mod, Func}, WsdlFile, Prefix } |
%% {{Mod, Func}, WsdlFile}
%% automatically setup in yaws_soap_srv init.
ysession_mod = yaws_session_server %% storage module for ysession
yaws, % server string
id = "default", % string identifying this instance of yaws
enable_soap = false, % start yaws_soap_srv iff true
soap_srv_mods = [], % a list of
% {{Mod, Func}, WsdlFile, Prefix } |
% {{Mod, Func}, WsdlFile}
% automatically setup in yaws_soap_srv init.
ysession_mod = yaws_session_server, % storage module for ysession
acceptor_pool_size = 8 % size of acceptor proc pool
}).


Expand Down
6 changes: 6 additions & 0 deletions man/yaws.conf.5
Expand Up @@ -138,6 +138,12 @@ as a proplist of valid process options. The supported options are
value. Other process options are ignored. The proplist may also be
empty. See \fBerlang:spawn_opt/4\fR for details on these options.

.TP
\fBacceptor_pool_size = Integer\fR
Set the size of the pool of cached acceptor processes. The specified
value must be greater than or equal to 0. The default value is
8. Specifying a value of 0 effectively disables the process pool.

.TP
\fBlog_wrap_size = Integer\fR
The logs written by yaws are all wrap logs, the default value at the
Expand Down
8 changes: 7 additions & 1 deletion scripts/yaws.conf.template
Expand Up @@ -34,9 +34,15 @@ keepalive_maxuses = nolimit
# connections that handle a lot of data. The default value is Erlang's
# default. Valid options are {fullsweep_after, X} and/or {min_heap_size, Y} where
# X and Y are integers. See Erlang's erlang:spawn_opt/4 function for more
# details. The value type is a quoted string containing an Erlang proplist.
# details. The value type is a quoted string containing an Erlang proplist or
# the atom undefined.
process_options = "[]"

# Set the size of the cached acceptor process pool. The value must be an
# integer greater than or equal to 0. The default pool size is 8. Setting
# the pool size to 0 effectively disables the pool.
#acceptor_pool_size = 8

# This is a debug variable, possible values are http | traffic | false
# It is also possible to set the trace (possibly to the tty) while
# invoking yaws from the shell as in
Expand Down
9 changes: 9 additions & 0 deletions src/yaws_config.erl
Expand Up @@ -661,6 +661,15 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) ->
{error, ?F("~s at line ~w", [Str, Lno])}
end;

["acceptor_pool_size", '=', Int] ->
case catch list_to_integer(Int) of
I when is_integer(I), I >= 0 ->
fload(FD, globals, GC#gconf{acceptor_pool_size = I},
C, Cs, Lno+1, Next);
_ ->
{error, ?F("Expect integer >= 0 at line ~w", [Lno])}
end;

["log_wrap_size", '=', Int] ->
case (catch list_to_integer(Int)) of
I when is_integer(I) ->
Expand Down
5 changes: 3 additions & 2 deletions src/yaws_server.erl
Expand Up @@ -592,11 +592,12 @@ gserv_loop(GS, Ready, Rnum, Last) ->
Int > 0 -> GS#gs{reqs = GS#gs.reqs+Int,
connections = GS#gs.connections - 1}
end,
PoolSize = (GS#gs.gconf)#gconf.acceptor_pool_size,
if
Rnum == 8 ->
Rnum == PoolSize ->
From ! {self(), stop},
?MODULE:gserv_loop(GS2, Ready, Rnum, Last);
Rnum < 8 ->
Rnum < PoolSize ->
%% cache this process for 10 secs
?MODULE:gserv_loop(GS2, [{now(), From} | Ready], Rnum+1, Last)
end;
Expand Down

0 comments on commit 028f2f0

Please sign in to comment.