How To Scale PHP Application
How To Scale PHP Application
http://www.zend.com
[email protected], [email protected]
Memcached
▶
▶ Redis
▶ Zend Server Cluster Manager
●
Scale horizontally (scale out)
▶ Add mores nodes to a system
▶ More servers, distributing the load
▶ High availability easy to implement
vs.
A Google server
●
We need load balancers to split the traffic
between all the servers
Load Balancer
Firewall
Internet
Web Servers
●
Session support in PHP consists of a way to preserve certain
data across subsequent accesses
●
To identify the subsequent accesses, from the same client,
PHP uses a cookie variable (PHPSESSID)
▶ Example: PHPSESSID= tclq3an1ri8dsfiuo43845loo1
●
By default, session data are stored in the file system of the
server
●
In PHP we manage the session data using the $_SESSION
global variable
●
Configure the PHP session management (php.ini directives):
▶ session.name
●
name of the session cookie identifier
(PHPSESSID by default)
▶ session.save_handler
●
defines the name of the handler which is used
for storing and retrieving data associated with
a session (files by default).
▶ session.save_path
●
defines the argument which is passed to the
save handler (with files handler is the path to
store the session data)
●
<?php
session_start();
$_SESSION['user']= 'enrico';
●
In session folder (for instance, /tmp) the PHP creates a file
named sess_fvi9r84f14sjel8r28o6aqspr2 (where
fvi9r84f14sjel8r28o6aqspr2 is PHPSESSID) that contains:
user|s:6:"enrico";
●
You can write your PHP session handler using
the session_set_save_handler():
bool session_set_save_handler (
callback $open,
callback $close,
callback $read,
callback $write,
callback $destroy,
callback $gc)
●
More info: http://php.net/manual/en/function.session-set-save-handler.php
▶ Ms SQL Server
●http://www.zimuel.it/blog/?p=402
▶ PostgreSQL, Oracle, etc
●
Zend Server is a complete, enterprise-ready
Web Application Server for running and
managing PHP applications that require a
high level of reliability, performance and
security on Linux, Windows or IBM i.
●
Zend Server Cluster Manager (ZSCM)
extends the benefits of Zend Server across
large-scale PHP deployments.
●
With ZSCM you can build a real PHP cluster
stack.
●
Session Clustering Extension
●
Session Clustering Daemon (SCD)
●
Storage backends: Disk / Memory
●
Peer-to-peer protocol to communicate
between nodes
●
Session management
with master-backup
architecture
MySQL
More info:
http://www.zend.com
http://phpconference.es