With the current fork rate of about 50 forks/second, we might think to switch to FastCGI and reduce the overall system cpu time. Although starting the interpreter binary is quite fast, the high fork rate nevertheless adds some overhead. By using FastCGI, the interpreter binary would be serving multiple requests instead with lower overhead.
To avoid memory leaks, all locations with static buffers would have to be cleared, before handling the next request. There's one new method initialize() in scripting_core.cc for this purpose. I'm sure there are other locations, which need to be cleared in a similar way - or - even completely changed like:
static std::map< uint32, string > roles; in method relation_member_roles (collect_members.cc).
static bool is_used_; for some statements like in area_query.h
Coord_Query_Statement::is_used_ in coord_query.cc
Id_Query_Statement::area_query_exists_ in id_query.cc
global_read_counter() in types.cc
- ... and similar
Settings used for the prototype:
Install libs:
sudo apt-get install libfcgi-dev
sudo apt-get install libapache2-mod-fcgid
Apache settings:
default.conf
<Directory "/srv/overpass/fcgi-bin/">
SetHandler fcgid-script
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</Directory>
fcgid.conf: (needs to be adjusted in any case)
<IfModule mod_fcgid.c>
FcgidConnectTimeout 60
FcgidMaxRequestsPerProcess 500
FcgidMaxProcessesPerClass 20
FcgidMinProcessesPerClass 10
FcgidProcessLifeTime 300
FcgidMaxProcesses 20
FcgidIOTimeout 1800
<IfModule mod_mime.c>
AddHandler fcgid-script .fcgi
</IfModule>
</IfModule>
With the current fork rate of about 50 forks/second, we might think to switch to FastCGI and reduce the overall system cpu time. Although starting the
interpreterbinary is quite fast, the high fork rate nevertheless adds some overhead. By using FastCGI, theinterpreterbinary would be serving multiple requests instead with lower overhead.To avoid memory leaks, all locations with static buffers would have to be cleared, before handling the next request. There's one new method initialize() in scripting_core.cc for this purpose. I'm sure there are other locations, which need to be cleared in a similar way - or - even completely changed like:
static std::map< uint32, string > roles;in method relation_member_roles (collect_members.cc).static bool is_used_;for some statements like in area_query.hCoord_Query_Statement::is_used_in coord_query.ccId_Query_Statement::area_query_exists_in id_query.ccglobal_read_counter()in types.ccSettings used for the prototype:
Install libs:
Apache settings:
default.conf
fcgid.conf: (needs to be adjusted in any case)