1. CakePHP Master/slave
*) Add default (slave as for query) setting in database.php, and master for saving
*) Define a new replicate behavior
Class Replicationbehavior extends Modelbehavior {
Public Function BeforeSave ($Model) {
$Model->usedbconfig = master;
}
Public Function Aftersave ($Model) {
$Model->usedbconfig = default;
}
Public Function Setserver ($Model, $server) {
$Model->__backupconfig = $Model->usedbconfig;
$Model->usedbconfig = $server;
}
Public Function Afterfind ($Model) {
if (!empty ($Model->__backupconfig)) {
$this->usedbconfig = $Model->__backupconfig;
}
$Model->__backupconfig = null;
}
Public Function Save ($data = null, $validate = true, $whitelist = Array ()) {
$this->replication->beforesave ($this);
Return Parent::save ($data, $validate, $whitelist);
}
}
?>
*) Set $actAs to has replicate behavior in your base app model
$actAs = Array (Replicate);
*) Call the Setserver method in your controller to determine which database you want to use for instant query after save
if ($this->deal->saveall ($this->data, Array (Validate=>first))) {
$this->deal->setserver (master);
$deal = $this->deal->find (First,array (
conditions = Array (slug = $this->data[deal][slug]),
Fields = Array (ID)
));
2 xhprof (a PHP benchmark tool developed by Facebook)
http://techportal.ibuildings.com/2009/12/01/profiling-with-xhprof/
3. MySQL load-balancing
Mysql-load-balancing-proxy-trafficscript ">http://www.zeus.com/community/articles/ Building-mysql-load-balancing-proxy-trafficscript
4. SSL
Consolidate secure operations to single domain:https://lang.secure.jigocity.com
Keep track of Referer links in HTTP header
Redirect back to the original Referer when done
http://www.bkjia.com/PHPjc/478813.html www.bkjia.com true http://www.bkjia.com/PHPjc/478813.html techarticle 1. CakePHP master/slave *) Add default (Slave as for query) setting in database.php, and Master for saving *) define a New replicate behavior? PHP class Replicationbehavior extends ...