42. HTTP Load Balancing:
Session Affinity
• (+) 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-affinity
• 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
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
• Configurability & 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 flushed to disk
• PHP resources wasted
• waiting for disk I/O
• waiting for lock on log files
• or logs go missing
103. fk-w3-agent:
Config & Discovery
• Change config without deployment?
104. fk-w3-agent:
Config & Discovery
• Change config without deployment?
• Simple: store config in a database
105. fk-w3-agent:
Config & Discovery
• Change config without deployment?
• Simple: store config in a database
• But: reloading config 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.”