Skip to content

Use FastCGI instead of CGI #209

@mmd-osm

Description

@mmd-osm

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>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions