42. HTTP Load Balancing:
Session AfďŹnity
⢠(+) Sessions can be stored on the web server
⢠(+) Different code on different web servers
⢠Useful for testing new code on a subset of users
⢠(-) If any web server goes down, need to migrate sessions
⢠(-) Not easy to take a web server out-of-rotation
44. HTTP Load Balancer:
Session Non-afďŹnity
⢠Sessions stored in a common session-store
⢠(+) Easy to manage -- all web servers have identical state
⢠(+) If a web server goes down -- no problem
⢠(+) Can take any web server out-of-rotation
⢠(-) Canât deploy to a subset of servers for testing
⢠(-) Central session-store could be slower
66. On the Web Servers
⢠PHP5
⢠Apache/mod_php
67. On the Web Servers
⢠PHP5
⢠Apache/mod_php
68. On the Web Servers
⢠PHP5
⢠Apache/mod_php
⢠Apache/mod_fcgid (FastCGI)
69. On the Web Servers
⢠PHP5
⢠Apache/mod_php
⢠Apache/mod_fcgid (FastCGI)
70. On the Web Servers
⢠PHP5
⢠Apache/mod_php
⢠Apache/mod_fcgid (FastCGI)
⢠PHP-FPM
71. On the Web Servers
⢠PHP5
⢠Apache/mod_php
⢠Apache/mod_fcgid (FastCGI)
⢠PHP-FPM
⢠PHP FastCGI Process Manager
⢠Great process management
⢠Security
⢠ConďŹgurability & control
⢠Adaptive process spawning (5.3.3RC1+)
73. On the Web Server:
fk-w3-agent
⢠Simple Java âmiddlewareâ daemon
74. On the Web Server:
fk-w3-agent
⢠Simple Java âmiddlewareâ daemon
⢠Deployed on each web server
75. On the Web Server:
fk-w3-agent
⢠Simple Java âmiddlewareâ daemon
⢠Deployed on each web server
⢠Communicates with PHP through local socket
76. On the Web Server:
fk-w3-agent
⢠Simple Java âmiddlewareâ daemon
⢠Deployed on each web server
⢠Communicates with PHP through local socket
⢠Hosts pluggable âhandlersâ
77. On the Web Server:
fk-w3-agent
⢠Simple Java âmiddlewareâ daemon
⢠Deployed on each web server
⢠Communicates with PHP through local socket
⢠Hosts pluggable âhandlersâ
88. fk-w3-agent: Logging
⢠We like to log, a lot
⢠Logs need to be ďŹushed to disk
⢠PHP resources wasted
⢠waiting for disk I/O
⢠waiting for lock on log ďŹles
⢠or logs go missing
92. fk-w3-agent:
Connection Pooling
⢠Many service calls / request
93. fk-w3-agent:
Connection Pooling
⢠Many service calls / request
⢠Cost of recreating connections high
94. fk-w3-agent:
Connection Pooling
⢠Many service calls / request
⢠Cost of recreating connections high
⢠PHP does not support connection pools*
103. fk-w3-agent:
ConďŹg & Discovery
⢠Change conďŹg without deployment?
104. fk-w3-agent:
ConďŹg & Discovery
⢠Change conďŹg without deployment?
⢠Simple: store conďŹg in a database
105. fk-w3-agent:
ConďŹg & Discovery
⢠Change conďŹg without deployment?
⢠Simple: store conďŹg in a database
⢠But: reloading conďŹg on each request: expensive
109. fk-w3-agent:
Running Statistics
⢠PHP sends basic stats to fk-w3-agent for every
request
⢠fk-w3-agent aggregates these stats
⢠Used for monitoring
112. To Cache or not to
Cache?
⢠âThere are only two hard things in Computer
Science: cache invalidation and naming thingsâ. --
Tim Bray quoting Phil Karlton
113. To Cache or not to
Cache?
⢠âThere are only two hard things in Computer
Science: cache invalidation and naming thingsâ. --
Tim Bray quoting Phil Karlton
⢠âThere are only two hard problems in Computer
Science: cache invalidation, naming things and off-by-1
errors.â