using fastcgi with apache http server
play

Using FastCGI with Apache HTTP Server FastCGI with Apache httpd - PowerPoint PPT Presentation

Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI Using FastCGI with Apache HTTP Server FastCGI with Apache httpd Comparisons between the contenders Jeff Trawick Configuration Future November 3, 2010 Table of


  1. What happened after that? Using FastCGI with Apache HTTP Server Jeff Trawick FastCGI was great for converting existing CGIs (often Perl) and drastically improving performance. The world of FastCGI But: FastCGI with Apache httpd Native web server APIs were exploited more and more, Comparisons between the either for existing scripting languages like Perl or new contenders languages like PHP. Configuration Apache httpd modules took off. Web developers and Future deployers became accustomed to native code plug-ins.

  2. What happened after that? Using FastCGI with Apache HTTP Server Jeff Trawick FastCGI was great for converting existing CGIs (often Perl) and drastically improving performance. The world of FastCGI But: FastCGI with Apache httpd Native web server APIs were exploited more and more, Comparisons between the either for existing scripting languages like Perl or new contenders languages like PHP. Configuration Apache httpd modules took off. Web developers and Future deployers became accustomed to native code plug-ins. (Surplus of C programmers?)

  3. Native module drawbacks Using FastCGI with Apache HTTP Server Overall resource use often larger when app runs in the web Jeff Trawick server, especially for prefork model The world of memory FastCGI connections to database, LDAP, etc. FastCGI with Apache httpd Resources are often left behind on any thread/process that Comparisons between the occasionally runs the application — underutilized. contenders Configuration Future

  4. Native module drawbacks Using FastCGI with Apache HTTP Server Overall resource use often larger when app runs in the web Jeff Trawick server, especially for prefork model The world of memory FastCGI connections to database, LDAP, etc. FastCGI with Apache httpd Resources are often left behind on any thread/process that Comparisons between the occasionally runs the application — underutilized. contenders Introduces instability into server Configuration Future

  5. Native module drawbacks Using FastCGI with Apache HTTP Server Overall resource use often larger when app runs in the web Jeff Trawick server, especially for prefork model The world of memory FastCGI connections to database, LDAP, etc. FastCGI with Apache httpd Resources are often left behind on any thread/process that Comparisons between the occasionally runs the application — underutilized. contenders Introduces instability into server Configuration Future Collisions between requirements of different modules

  6. Native module drawbacks Using FastCGI with Apache HTTP Server Overall resource use often larger when app runs in the web Jeff Trawick server, especially for prefork model The world of memory FastCGI connections to database, LDAP, etc. FastCGI with Apache httpd Resources are often left behind on any thread/process that Comparisons between the occasionally runs the application — underutilized. contenders Introduces instability into server Configuration Future Collisions between requirements of different modules Generally unable to support multiple script interpreter versions

  7. Native module drawbacks Using FastCGI with Apache HTTP Server Overall resource use often larger when app runs in the web Jeff Trawick server, especially for prefork model The world of memory FastCGI connections to database, LDAP, etc. FastCGI with Apache httpd Resources are often left behind on any thread/process that Comparisons between the occasionally runs the application — underutilized. contenders Introduces instability into server Configuration Future Collisions between requirements of different modules Generally unable to support multiple script interpreter versions Potential lack of thread safety, or expensive locking

  8. But with FastCGI Using FastCGI with Apache HTTP Server Often the required application thread/process count is a Jeff Trawick fraction of that of the web server (so resources not left The world of FastCGI behind on threads/processes occasionally used). FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  9. But with FastCGI Using FastCGI with Apache HTTP Server Often the required application thread/process count is a Jeff Trawick fraction of that of the web server (so resources not left The world of FastCGI behind on threads/processes occasionally used). FastCGI with A particular application usually can’t introduce instability Apache httpd into the server, so basic services and other applications are Comparisons between the unaffected. contenders Configuration Future

  10. But with FastCGI Using FastCGI with Apache HTTP Server Often the required application thread/process count is a Jeff Trawick fraction of that of the web server (so resources not left The world of FastCGI behind on threads/processes occasionally used). FastCGI with A particular application usually can’t introduce instability Apache httpd into the server, so basic services and other applications are Comparisons between the unaffected. contenders Configuration Different applications can use different libraries, interpreter Future versions, framework versions, etc.

  11. But with FastCGI Using FastCGI with Apache HTTP Server Often the required application thread/process count is a Jeff Trawick fraction of that of the web server (so resources not left The world of FastCGI behind on threads/processes occasionally used). FastCGI with A particular application usually can’t introduce instability Apache httpd into the server, so basic services and other applications are Comparisons between the unaffected. contenders Configuration Different applications can use different libraries, interpreter Future versions, framework versions, etc. Independent start/stop of web server and application

  12. But with FastCGI Using FastCGI with Apache HTTP Server Often the required application thread/process count is a Jeff Trawick fraction of that of the web server (so resources not left The world of FastCGI behind on threads/processes occasionally used). FastCGI with A particular application usually can’t introduce instability Apache httpd into the server, so basic services and other applications are Comparisons between the unaffected. contenders Configuration Different applications can use different libraries, interpreter Future versions, framework versions, etc. Independent start/stop of web server and application Independent identity or chroot env vs. web server and other applications

  13. Criticisms of FastCGI Using FastCGI protocol is too complex to implement with Apache HTTP Server Jeff Trawick but a number of language bindings share the same core, The world of the Open Market C-language interface FastCGI FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  14. Criticisms of FastCGI Using FastCGI protocol is too complex to implement with Apache HTTP Server Jeff Trawick but a number of language bindings share the same core, The world of the Open Market C-language interface FastCGI FastCGI with defines many more features than are actually used (or at Apache httpd least working in practice) Comparisons between the lack of support for FastCGI filtering contenders lack of support for FastCGI management queries Configuration AAA broken in mod fcgid for years (still waiting for 2.3.6) Future who needs it?

  15. Criticisms of FastCGI Using FastCGI protocol is too complex to implement with Apache HTTP Server Jeff Trawick but a number of language bindings share the same core, The world of the Open Market C-language interface FastCGI FastCGI with defines many more features than are actually used (or at Apache httpd least working in practice) Comparisons between the lack of support for FastCGI filtering contenders lack of support for FastCGI management queries Configuration AAA broken in mod fcgid for years (still waiting for 2.3.6) Future who needs it? generally troublesome implementations just switch from mod fastcgi to mod fcgid or httpd to Lighttpd or ...

  16. Concerns for some special situations Using FastCGI with Apache HTTP Server Jeff Trawick The world of Protocol is complex enough that unsanitized input could FastCGI expose bugs in non-mainstream protocol support in app FastCGI with Apache httpd but also in server Comparisons between the contenders Configuration Future

  17. Concerns for some special situations Using FastCGI with Apache HTTP Server Jeff Trawick The world of Protocol is complex enough that unsanitized input could FastCGI expose bugs in non-mainstream protocol support in app FastCGI with Apache httpd but also in server Comparisons between the Care needed with TCP to protect access contenders Instant auth: Just set REMOTE USER Configuration Throw garbage at the TCP port, see what happens Future AF UNIX has filesystem permissions and is system-only.

  18. Competitors Using FastCGI with Apache HTTP Server Jeff Trawick HTTP — If you use HTTP you can interoperate with The world of almost anything. But if you use HTTP you have a lot to FastCGI implement to be able to interoperate with what people will FastCGI with Apache httpd throw at you. Comparisons between the SCGI — http://python.ca/scgi/protocol.txt contenders about 100 lines, so easy to implement yourself if existing Configuration library support isn’t available or suitable Future commonly used FastCGI capabilities, plus sendfile One unfortunate omission: doesn’t provide a way for routing stderr messages (integration into web server logs).

  19. Competitors Using FastCGI with Apache HTTP Server Jeff Trawick CGI — why not, if load isn’t an issue? The world of FastCGI AJP — not just for Java application servers FastCGI with Apache httpd custom Comparisons between the These have varying infrastructure to help with process contenders management and protocol. Configuration Future (And of course mod foo and JVM or CLR-based interpreters.)

  20. FastCGI modules for Apache htttpd Using FastCGI Two contenders in this space with Apache HTTP Server mod fastcgi Jeff Trawick http://www.fastcgi.com/ The world of the original FastCGI often referred to as outdated and unmaintained, though it FastCGI with is still actively used and there was a snapshot created in Apache httpd 2009 (last release was 2.4.6 in 2007) Comparisons between the supports httpd 1.3–2.2 (and probably needs just a few contenders tweaks to support 2.4-dev) Configuration Future

  21. FastCGI modules for Apache htttpd Using FastCGI Two contenders in this space with Apache HTTP Server mod fastcgi Jeff Trawick http://www.fastcgi.com/ The world of the original FastCGI often referred to as outdated and unmaintained, though it FastCGI with is still actively used and there was a snapshot created in Apache httpd 2009 (last release was 2.4.6 in 2007) Comparisons between the supports httpd 1.3–2.2 (and probably needs just a few contenders tweaks to support 2.4-dev) Configuration mod fcgid Future http://httpd.apache.org/mod fcgid/ originally created by Ryan Pan in 2004 and published under GPL; hosted at SourceForge donated and relicensed to ASF in 2009; now developed and released as a subproject of Apache httpd supports httpd 2.0–2.4-dev

  22. Proxy scheme modules Using FastCGI with Apache HTTP Server Jeff Trawick Two separately maintained proxy scheme modules: The world of FastCGI mod proxy fcgi in Apache httpd 2.4-dev FastCGI with covered more later Apache httpd Comparisons mod proxy fcgi at SourceForge between the contenders Because it is limited to httpd 2.0, it doesn’t support load Configuration balancing. Future not discussed further They support only externally managed servers over TCP/IP.

  23. Which mod fcgid? Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI FastCGI with 2.2 was the only release for a long time, and some Apache httpd important patches accumulated in the source tree, Comparisons between the SourceForge bug db, and in private trees. contenders Not all of that has made its way to ASF mod fcgid. Configuration Future

  24. Capability differences Using FastCGI with Apache HTTP Server Jeff Trawick mod fastcgi has The world of FastCGI load balancing to FastCGI processes FastCGI with Apache httpd statically defined and externally managed FastCGI Comparisons processes between the contenders support for FastCGI apps which can handle multiple Configuration concurrent requests or include their own process Future management other less-important features

  25. Capability differences Using FastCGI with Apache HTTP Server Jeff Trawick mod fcgid has The world of better option configuration for dynamically started FastCGI FastCGI processes FastCGI with Apache httpd monitoring of processes via mod status reports Comparisons between the arguably better configuration of process management contenders parameters Configuration Future arguably better documentation neither has X-Sendfile, unlike Lighttpd

  26. Logging differences Using FastCGI with Apache HTTP Server Jeff Trawick The world of mod fastcgi writes a lot of information about process FastCGI management at LogLevel warn FastCGI with Apache httpd 2009 snapshot has same bogus error info logged that has Comparisons between the been around for a long time contenders mod fcgid uses LogLevel info for similar information Configuration but before 2.3.5 it used LogLevel notice — unsuppressible Future – for some common messages

  27. Other possible considerations — Licensing Using FastCGI with Apache HTTP Server Jeff Trawick The world of mod fastcgi is not considered a free software license. FastCGI mod fastcgi and any derivatives are licensed for the sole FastCGI with Apache httpd purpose of implementing FastCGI specs defined or Comparisons between the endorsed by Open Market. contenders (The Open Market license for FastCGI libraries has no Configuration such restriction.) Future No issues with ASL 2.0.

  28. Other possible considerations — Dev processes Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI mod fcgid — Code repos, releases, security issues, bug FastCGI with reporting, development discussions, etc. are the same as Apache httpd the server itself. Comparisons between the contenders mod fastcgi — Code on a git repo at http://repo.or.cz, Configuration not much recent history of releases or security process, Future bug reporting on the fastcgi.com-hosted mailing list.

  29. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick The world of FastCGI FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  30. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  31. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  32. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons between the contenders Configuration Future

  33. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons mod fcgid more stable than mod fastcgi between the contenders Configuration Future

  34. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons mod fcgid more stable than mod fastcgi between the contenders mod fcgid results in less system memory consumed than Configuration mod fastcgi Future

  35. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons mod fcgid more stable than mod fastcgi between the contenders mod fcgid results in less system memory consumed than Configuration mod fastcgi Future mod fastcgi has issues with dead FastCGI processes

  36. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons mod fcgid more stable than mod fastcgi between the contenders mod fcgid results in less system memory consumed than Configuration mod fastcgi Future mod fastcgi has issues with dead FastCGI processes AF UNIX sockets not reliable

  37. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons mod fcgid more stable than mod fastcgi between the contenders mod fcgid results in less system memory consumed than Configuration mod fastcgi Future mod fastcgi has issues with dead FastCGI processes AF UNIX sockets not reliable PHP before version x.y.z had bad process management

  38. Comments on the web Using FastCGI with Apache HTTP Server mod php faster Jeff Trawick PHP over FastCGI about as fast The world of FastCGI mod fastcgi faster than mod fcgid FastCGI with mod fcgid faster than mod fastcgi Apache httpd Comparisons mod fcgid more stable than mod fastcgi between the contenders mod fcgid results in less system memory consumed than Configuration mod fastcgi Future mod fastcgi has issues with dead FastCGI processes AF UNIX sockets not reliable PHP before version x.y.z had bad process management “Paul said MoinMoin didn’t work with fcgid.”

  39. Comments on the web Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI What is true? FastCGI with Apache httpd Everything? Comparisons Nothing? between the contenders 10%, the rest just being bad configuration and/or simple Configuration but undiagnosed bugs? Future

  40. The definitive source of knowledge Using FastCGI with Apache HTTP Server Jeff Trawick Let’s put this to rest once and for all! The world of FastCGI FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  41. The definitive source of knowledge Using FastCGI with Apache HTTP Server Jeff Trawick Let’s put this to rest once and for all! The world of FastCGI FastCGI with “mod fastcgi sucks” Apache httpd Comparisons between the contenders Configuration Future

  42. The definitive source of knowledge Using FastCGI with Apache HTTP Server Jeff Trawick Let’s put this to rest once and for all! The world of FastCGI FastCGI with “mod fastcgi sucks” Apache httpd Comparisons between the 3 hits on google contenders Configuration Future

  43. The definitive source of knowledge Using FastCGI with Apache HTTP Server Jeff Trawick Let’s put this to rest once and for all! The world of FastCGI FastCGI with “mod fastcgi sucks” Apache httpd Comparisons between the 3 hits on google contenders Configuration Future “mod fcgid sucks”

  44. The definitive source of knowledge Using FastCGI with Apache HTTP Server Jeff Trawick Let’s put this to rest once and for all! The world of FastCGI FastCGI with “mod fastcgi sucks” Apache httpd Comparisons between the 3 hits on google contenders Configuration Future “mod fcgid sucks” 0 hits on google

  45. Quick and dirty performance test, no configuration Using FastCGI with Apache HTTP Server Jeff Trawick The world of 1k response, 1 concurrent client (ab -n 10000 -c 1), ignore first FastCGI run FastCGI with Apache httpd Comparisons Handler Requests/second between the contenders fastcgi 1073, 1281, 1495, 1065, 1145 Configuration fcgid 969, 1102, 965, 990, 1077 Future cgid 35, 35

  46. Quick and dirty performance test, no configuration Using FastCGI with Apache HTTP Server Jeff Trawick The world of 8k response, 120 concurrent clients (ab -n 10000 -c 120), FastCGI ignore first run FastCGI with Apache httpd Comparisons Handler Requests/second Processes between the contenders fastcgi 2680, 2662, 2646, 2646, 2647 1 Configuration fcgid 2933, 2906, 2826, 2958, 2944 15 Future cgid 62, 61 n

  47. mod fcgid: syscalls for script when already started Using FastCGI with Apache HTTP Server Jeff Trawick [pid 31334] semop(5636097, {{0, -1, SEM_UNDO}}, 1) = 0 [pid 31334] semop(5636097, {{0, 1, SEM_UNDO}}, 1) = 0 [pid 31334] socket(PF_FILE, SOCK_STREAM, 0) = 16 The world of [pid 31334] connect(16, {sa_family=AF_FILE, FastCGI path="/home/trawick/ApacheCon/inst/logs/fcgidsock/31221.2"}, 110) = 0 [pid 31334] setsockopt(16, SOL_TCP, TCP_NODELAY, [1], 4) FastCGI with = -1 EOPNOTSUPP (Operation not supported) Apache httpd [pid 31334] fcntl64(16, F_GETFL) = 0x2 (flags O_RDWR) Comparisons [pid 31334] fcntl64(16, F_SETFL, O_RDWR|O_NONBLOCK) = 0 between the [pid 31334] gettimeofday({1288725238, 241008}, NULL) = 0 contenders [pid 31334] writev(16, [{"\1\1\0\1\0\10\0\0", 8}, {"\0\1\0\0\0\0\0\0", 8}, {"\1\4\0\1\2\314\0\0", 8}, Configuration {"\t\16HTTP_HOST127.0.0.1:8080\17\17HTTP_"..., 716}, {"\1\4\0\1\0\0\0\0", 8}, {"\1\5\0\1\0\0\0\0", 8}, {NULL, 0}], 7) = 756 Future [pid 31334] read(16, 0x90341a8, 8192) = -1 EAGAIN (Resource temporarily unavailable) [pid 31334] poll([{fd=16, events=POLLIN}], 1, 40000) = 1 ([{fd=16, revents=POLLIN}]) [pid 31334] read(16, "\1\6\0\1\4\32\6\0Content-Type: text/plain"..., 8192) = 1088 [pid 31334] gettimeofday({1288725238, 241663}, NULL) = 0 [pid 31334] close(16) = 0 [pid 31334] semop(5636097, {{0, -1, SEM_UNDO}}, 1) = 0 [pid 31334] semop(5636097, {{0, 1, SEM_UNDO}}, 1) = 0

  48. mod fastcgi: syscalls for script when already started Using FastCGI with Apache HTTP Server Jeff Trawick [pid 31305] stat64("/home/trawick/ApacheCon/inst/logs/fastcgi/dynamic/ 5cb5cbf10efa67823cdd3e00cbac2a8d", {st_mode=S_IFSOCK|0600, st_size=0, ...}) = 0 The world of [pid 31305] socket(PF_FILE, SOCK_STREAM, 0) = 16 FastCGI [pid 31305] gettimeofday({1288726660, 499152}, NULL) = 0 [pid 31305] connect(16, {sa_family=AF_FILE, path="/home/trawick/ApacheCon/inst/logs/ FastCGI with fastcgi/dynamic/5cb5cbf10efa67823cdd3e00cbac2a8d"}, 84) = 0 Apache httpd [pid 31305] fcntl64(16, F_GETFL) = 0x2 (flags O_RDWR) [pid 31305] fcntl64(16, F_SETFL, O_RDWR|O_NONBLOCK) = 0 Comparisons [pid 31305] gettimeofday({1288726660, 502717}, NULL) = 0 between the [pid 31305] select(17, [16], [16], NULL, {3, 96435}) = 1 (out [16], left {3, 96423}) contenders [pid 31305] write(16, "\1\1\0\1\0\10\0\0\0\1\0\0\0\0\0\0\1\4 \0\1\0\31\0\0\t\16HTTP_H"..., 886) = 886 Configuration [pid 31305] gettimeofday({1288726660, 503126}, NULL) = 0 [pid 31305] select(17, [16], [], NULL, {3, 96026}) = 1 (in [16], left {3, 95540}) Future [pid 31305] gettimeofday({1288726660, 503821}, NULL) = 0 [pid 31305] read(16, "\1\6\0\1\4\32\6\0Content-Type: text/plain"..., 8192) = 1088 [pid 31305] fcntl64(16, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK) [pid 31305] fcntl64(16, F_SETFL, O_RDWR) = 0 [pid 31305] setsockopt(16, SOL_SOCKET, SO_LINGER, {onoff=0, linger=0}, 8) = 0 [pid 31305] close(16)

  49. Syscall summary Using FastCGI with Apache HTTP Server Jeff Trawick The world of mod fcgid has, mod fastcgi doesn’t: FastCGI setsockopt(TCP NODELAY) EOPNOTSUPP FastCGI with Apache httpd writev() for 756 bytes with wasted element Comparisons between the read() EAGAIN contenders Configuration poll() Future two lock/unlock sequences

  50. Syscall summary Using FastCGI with Apache HTTP Server mod fastcgi has, mod fcgid doesn’t: Jeff Trawick stat() The world of FastCGI two more calls to gettimeofday() FastCGI with write() for 886 bytes Apache httpd Comparisons select() between the contenders bad for platforms with small FD SETSIZE and heavily Configuration threaded MPM child processes Future fcntl(turn off non-blocking) setsockopt(disable linger) The unexpected socket calls make more sense when using TCP sockets.

  51. Simple CGI and FastCGI configuration Using FastCGI with Apache HTTP Server Start with CGI: Jeff Trawick Alias /fastcgi/ \ The world of FastCGI /home/trawick/ApacheCon/inst/fastcgi/ FastCGI with Apache httpd <Location /fastcgi> Comparisons between the Options +ExecCGI contenders SetHandler cgi-script Configuration </Location> Future IOW, enable the ExecCGI option and set the handler appropriately. (ScriptAlias kind-of does that) Change the handler name to fcgid-script (mod fcgid) or fastcgi-script (mod fastcgi).

  52. More classic CGI configuration Using FastCGI with Apache HTTP Server Jeff Trawick <Location /myapp/> The world of AddHandler prettify txt FastCGI Action prettify /tools/prettify.pl FastCGI with Apache httpd </Location> Comparisons between the contenders <Directory /www/tools/> Configuration Options +ExecCGI Future SetHandler cgi-script </Directory> Again, change the handler name to fcgid-script (mod fcgid) or fastcgi-script (mod fastcgi).

  53. Is that all? Using FastCGI with Apache HTTP Server Jeff Trawick It might be, unless... The world of default timeouts or other I/O settings aren’t okay FastCGI connect timeout, read/write timeout, hang detection FastCGI with Apache httpd Comparisons between the contenders Configuration Future

  54. Is that all? Using FastCGI with Apache HTTP Server Jeff Trawick It might be, unless... The world of default timeouts or other I/O settings aren’t okay FastCGI connect timeout, read/write timeout, hang detection FastCGI with Apache httpd default process management isn’t okay Comparisons between the contenders Configuration Future

  55. Is that all? Using FastCGI with Apache HTTP Server Jeff Trawick It might be, unless... The world of default timeouts or other I/O settings aren’t okay FastCGI connect timeout, read/write timeout, hang detection FastCGI with Apache httpd default process management isn’t okay Comparisons between the limits on numbers of processes, rules for shrinking the pool contenders Configuration Future

  56. Is that all? Using FastCGI with Apache HTTP Server Jeff Trawick It might be, unless... The world of default timeouts or other I/O settings aren’t okay FastCGI connect timeout, read/write timeout, hang detection FastCGI with Apache httpd default process management isn’t okay Comparisons between the limits on numbers of processes, rules for shrinking the pool contenders minor protocol adjustments, environment variables, etc. Configuration Future

  57. Is that all? Using FastCGI with Apache HTTP Server Jeff Trawick It might be, unless... The world of default timeouts or other I/O settings aren’t okay FastCGI connect timeout, read/write timeout, hang detection FastCGI with Apache httpd default process management isn’t okay Comparisons between the limits on numbers of processes, rules for shrinking the pool contenders minor protocol adjustments, environment variables, etc. Configuration Future Additional configuration is likely except for sites with only relatively simple FastCGI applications.

  58. mod fcgid Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI FastCGI with Apache httpd All mod fcgid configuration from this point! Comparisons between the contenders Configuration Future

  59. Hung process detection Using FastCGI with Apache HTTP Server By default, if a request does not complete within five minutes Jeff Trawick the application will be terminated. The world of No way to disable. Fixme. FastCGI FastCGI with Apache httpd # my report generates output over a long period of Comparisons between the # time; don’t kill it contenders FcgidBusyTimeout 3600 Configuration Future # kill anything that doesn’t respond within 30 # seconds FcgidBusyTimeout 30

  60. I/O timeouts (hung process?) Using FastCGI with Apache HTTP Server Jeff Trawick By default, if no data can be read or written within 40 seconds, The world of the application will be terminated. FastCGI FastCGI with Apache httpd # my report generates output over a long period of Comparisons # time; don’t kill it between the contenders FcgidBusyTimeout 3600 Configuration # oh, and there are long pauses between generation Future # of any output FcgidIOTimeout 300

  61. Process management Using FastCGI with Apache HTTP Server Jeff Trawick Simple stuff: The world of FcgidMaxProcesses — global limit on number of processes FastCGI FastCGI with FcgidMaxProcessesPerClass — limit on number of Apache httpd processes per application Comparisons between the FcgidIdleTimeout — termination after idle for this long contenders Configuration FcgidMaxRequestsPerProcess — termination after Future handling this many requests FcgidProcessLifetime — termination after alive for this long

  62. Tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI Spawn score: internal calculation which represents process activity for a FastCGI application; used to determine if a new FastCGI with Apache httpd instance (process) can be created. Comparisons between the # Set this high. If actual score is higher for an app, contenders # more instances can’t be created. Configuration FcgidSpawnScoreUpLimit 7000 Future

  63. Tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick Spawn score: internal calculation which represents process The world of FastCGI activity for a FastCGI application; used to determine if a new FastCGI with instance (process) can be created. Apache httpd Comparisons FcgidSpawnScoreUpLimit 7000 between the contenders # Default value. Each process creation adds this to the Configuration # score. Future FcgidSpawnScore 1

  64. Tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick Spawn score: internal calculation which represents process The world of activity for a FastCGI application; used to determine if a new FastCGI instance (process) can be created. FastCGI with Apache httpd FcgidSpawnScoreUpLimit 7000 Comparisons FcgidSpawnScore 1 between the contenders Configuration # By default, termination increases the score. But why? # If a process goes away, create additional headroom for Future # creating a replacement. FcgidTerminationScore -1

  65. Tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick Spawn score: internal calculation which represents process The world of activity for a FastCGI application; used to determine if a new FastCGI instance (process) can be created. FastCGI with Apache httpd FcgidSpawnScoreUpLimit 7000 Comparisons between the FcgidSpawnScore 1 contenders FcgidTerminationScore -1 Configuration Future # Subtracted from the score each second. FcgidTimeScore 3

  66. Ugly tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI mod fcgid scans for certain conditions at configurable intervals. The default values for the intervals are quite high for some — FastCGI with Apache httpd 120 seconds. Comparisons between the # Scan for processes which have exceeded idle timeout every contenders # second. Configuration FcgidIdleScanInterval 0 Future

  67. Ugly tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick The world of mod fcgid scans for certain conditions at configurable intervals. FastCGI The default values for the intervals are quite high for some — FastCGI with 120 seconds. Apache httpd Comparisons between the FcgidIdleScanInterval 0 contenders Configuration # Scan for processes which need to be terminated every second. Future FcgidErrorScanInterval 0

  68. Ugly tuning of process management algorithms Using FastCGI with Apache HTTP Server Jeff Trawick mod fcgid scans for certain conditions at configurable intervals. The world of The default values for the intervals are quite high for some — FastCGI 120 seconds. FastCGI with Apache httpd FcgidIdleScanInterval 0 Comparisons FcgidErrorScanInterval 0 between the contenders Configuration # Scan for zombie processes every second. # (Why don’t we just call waitpid() to see if any children Future # exited?) FcgidZombieScanInterval 0

  69. Wrappers Using FastCGI with Apache HTTP Server a command which will run for certain requests — by Jeff Trawick container or extension The world of typically is outside of the web space FastCGI FastCGI with typically is a script which encapsulates command-line Apache httpd parameters and environment settings such as envvars and Comparisons between the ulimits contenders Configuration <Location /phpapp/> Future AddHandler fcgid-script .php Options +ExecCGI FcgidWrapper /usr/local/bin/php-wrapper .php </Location>

  70. Command-specific options Using FastCGI with Apache HTTP Server Jeff Trawick Most directives apply to every app in a certain container (vhost or per-dir). The world of FastCGI FcgidCmdOptions allows many directives to be applied for a FastCGI with single specific command. Apache httpd Comparisons between the FcgidCmdOptions /path/to/info.pl \ contenders IdleTimeout 30 \ Configuration InitialEnv VHOST=www2.example.com \ Future IOTimeout 5 \ MaxRequestsPerProcess 10000

  71. Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI FastCGI with Apache httpd Jeff, this is where you show the sample server-status page. Comparisons between the contenders Configuration Future

  72. PHP and FastCGI Using FastCGI with Apache HTTP Server Jeff Trawick Not at all uncommon... The world of FastCGI FastCGI required or recommended for PHP with FastCGI with Apache httpd Comparisons nginx between the contenders Lighttpd Configuration Zeus Future IIS

  73. PHP and FastCGI Using FastCGI with Apache HTTP Server Jeff Trawick Not at all uncommon... The world of FastCGI FastCGI required or recommended for PHP with FastCGI with Apache httpd Comparisons nginx between the contenders Lighttpd Configuration Zeus Future IIS Can work fine with Apache httpd too

  74. Special considerations Using FastCGI with Apache HTTP Server PHP FastCGI processes normally exit after 500 requests Jeff Trawick The world of Synchronize mod fcgid and PHP limits to avoid 500 error 1 . FastCGI FastCGI with Apache httpd Comparisons between the contenders Configuration Future 1 The HTTP error code and the request count are both 500. Conspiracy?

  75. Special considerations Using FastCGI with Apache HTTP Server PHP FastCGI processes normally exit after 500 requests Jeff Trawick The world of Synchronize mod fcgid and PHP limits to avoid 500 error 1 . FastCGI FastCGI with Apache httpd In PHP wrapper: Comparisons between the PHP_FCGI_MAX_REQUESTS=10000 contenders In fcgid configuration: Configuration Future FcgidMaxRequestsPerProcess 10000 or just set PHP FCGI MAX REQUESTS to 0 to disable 1 The HTTP error code and the request count are both 500. Conspiracy?

  76. Special considerations Using FastCGI with Apache HTTP Server Jeff Trawick PHP FastCGI process management ineffective (wasted) The world of with mod fcgid, which routes only single concurrent FastCGI FastCGI with requests to the socket of a process which it has spawned. Apache httpd Comparisons Leave PHP child process management disabled between the contenders (PHP FCGI CHILDREN=0). Configuration Future

  77. Special considerations Using FastCGI with Apache HTTP Server Jeff Trawick PHP FastCGI process management ineffective (wasted) The world of with mod fcgid, which routes only single concurrent FastCGI FastCGI with requests to the socket of a process which it has spawned. Apache httpd Comparisons Leave PHP child process management disabled between the contenders (PHP FCGI CHILDREN=0). Configuration Future not an issue with mod fastcgi, though there are lingering complaints that PHP process management is problematic anyway

  78. Special considerations Using FastCGI with Apache HTTP Server Jeff Trawick The world of But: FastCGI With PHP process management, single cache can be used FastCGI with Apache httpd concurrently by many processes. Comparisons between the contenders Configuration Future

  79. Special considerations Using FastCGI with Apache HTTP Server Jeff Trawick The world of But: FastCGI With PHP process management, single cache can be used FastCGI with Apache httpd concurrently by many processes. Comparisons between the Without PHP child process management, PHP opcode contenders caches are not very effective. Cache is serially reused Configuration within single process when the same fcgid-spawned process Future handles another request.

  80. More oddities Using FastCGI with Apache HTTP Server Jeff Trawick The world of FastCGI FastCGI with PHP flags in .htaccess files — no longer respected when Apache httpd you move from mod php to FastCGI Comparisons between the on Windows, mod php strips the drive letter from contenders SCRIPT NAME; mod fcgid doesn’t Configuration Future

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend