FastCGI

From UGCS
(Difference between revisions)
Jump to: navigation, search
(New page: =Problem Definition= ==Problems to solve== * PHP performance is really bad- it takes 0.3s to load the simple test pages we have * Since php is run as a cgi every time, it cannot do opcode ...)
 
Line 38: Line 38:
 
** The disadvantage is that fcgi doesn't like completely stopping static instances
 
** The disadvantage is that fcgi doesn't like completely stopping static instances
 
* We'll just tell users that fcgi is only enabled on vhosts, many users use the vhost service anyways
 
* We'll just tell users that fcgi is only enabled on vhosts, many users use the vhost service anyways
 +
 +
==Todo==
 +
* Install it on dionysus
 +
* Set up a test vhost
 +
* Add User/Group to each vhost definition
 +
* Modify the wrapper scripts
 +
** Still needs to be suid since we are using mod_fastcgi which runs under apache's uid/gid
 +
** Remove the pagsh since we will have k5start make a new one
 +
** Use user/group from command line instead of parsing the URL
 +
** Change uid before getting tokens
 +
** Set the environment for php-cgi so it does the right things with fcgi
 +
** Set it up so that we have k5start ... -t -- php-cgi
 +
  
 
[[Category:Sysadmin_Documentation]]
 
[[Category:Sysadmin_Documentation]]

Revision as of 19:44, 10 February 2010

Contents

Problem Definition

Problems to solve

  • PHP performance is really bad- it takes 0.3s to load the simple test pages we have
  • Since php is run as a cgi every time, it cannot do opcode caching

Constraints

  • Stuff must be run through our wrapper scripts
  • We have finite resources on posiedon and can't exhaust them by leaving one or two processes open for every user

Desired outcomes

  • Something that lets php keep running so it doesn't have to re-initialize every time

Implementation

FastCGI docs

Details

  • Works on a per-vhost level
  • We want a dynamic application so that the fastcgi server can start/stop things as needed
  • We will set up a FastCGIConfig for each virtual server
  • Each virtual server will also have a FastCgiWrapper set up that points to the vhost wrapper script
  • Each vhost will also need the apache User and Group directives set (these normally only apply to suEXEC, which we aren't running so their only effect is to tell FastCGI which user/group)
  • php-cgi needs to be told to not run its own process manager so fcgi can start/stop it as necessary
    • Maybe we can have php-cgi start 2 or 3 threads?

Why it only works for PHP

  • FastCGI doesn't seem to support having multiple different dynamic services
  • The dyanmic service (through a wrapper) will start the php-cgi which runs as a fastcgi service.
  • Since php-cgi will be running as the application (and it gets passed filename requests), it can't do normal cgi
  • This isn't really a problem because normal cgi stuff will continue to work as normal cgi
  • This solves our biggest problem anyways which is php initialization/parsing time

Why the dynamic service only works for vhosts

  • I don't think there is any way to specify User/Group on a per-directory basis, so fcgi can't set up a new application instance for every new user
  • We could set up static instances on a per-user basis, where each static user knew what user to run as
    • The disadvantage is that fcgi doesn't like completely stopping static instances
  • We'll just tell users that fcgi is only enabled on vhosts, many users use the vhost service anyways

Todo

  • Install it on dionysus
  • Set up a test vhost
  • Add User/Group to each vhost definition
  • Modify the wrapper scripts
    • Still needs to be suid since we are using mod_fastcgi which runs under apache's uid/gid
    • Remove the pagsh since we will have k5start make a new one
    • Use user/group from command line instead of parsing the URL
    • Change uid before getting tokens
    • Set the environment for php-cgi so it does the right things with fcgi
    • Set it up so that we have k5start ... -t -- php-cgi
Personal tools