Permalink
Browse files

add config setting for acceptor pool size

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...
1 parent 914a52f commit 028f2f084b167c0f67db99efd816a25b3bdf00e2 @vinoski vinoski committed Sep 26, 2011
Showing with 40 additions and 11 deletions.
  1. +6 −0 doc/yaws.tex
  2. +9 −8 include/yaws.hrl
  3. +6 −0 man/yaws.conf.5
  4. +7 −1 scripts/yaws.conf.template
  5. +9 −0 src/yaws_config.erl
  6. +3 −2 src/yaws_server.erl
View
@@ -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}
View
@@ -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
}).
View
@@ -139,6 +139,12 @@ 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
size where they wrap around and the original gets renamed to File.old
@@ -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
View
@@ -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) ->
View
@@ -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;

0 comments on commit 028f2f0

Please sign in to comment.