eZ Cluster unleashedThe return
Purpose and historyOne eZ Publish on multiple servers, for:PerformanceRedundancyCreated for eZ Publish 3.8, vastly improve...
Cluster handlers           eZ DB                        eZ DFSFrom eZ Publish 3.8           From eZ Publish 4.2Stores meta...
HTTP vs Internal callsHTTPRequests done through index_cluster.phpServes files directlyA reverse proxy caches images & bina...
Configuration #1: file.iniA cluster handler must be configured in a file.ini override:1.[ClusteringSettings]2.FileHandler=...
Configuration #2: databaseeZDB and eZDFS both require database tablesThe same DB server can be usedPerformance wise it is ...
Configuration #3: clusterizeExisting local files must be moved to the clusterThis  is done using bin/php/clusterize.phpThi...
Configuration #4: binary URLs rewritingURL rewriting is required to "stream" clusterized binary files tovisitors:   Images...
Configuration #5: binary files indexThe cluster index handles binary files HTTP requestsIt doesnt use the whole kernel in ...
Configuration #5: binary files index, example/** * Cluster configuration file */define( CLUSTER_STORAGE_BACKEND,    dfsmys...
How cache is handledRemote, clusterized files are copied locallyBefore using a local file, eZ always checks if it is newer...
API: reading clusterized files1.$path = /var/ezwebin_site/path/to/my/file.txt1.// read a text file, "instance" syntax2.$co...
API: writing a file to the clusterAgain, the native PHP I/O API isnt cluster aware !1.// stores the contents of the $conte...
API: ViewCache !ViewCache uses advanced methods of the cluster APIThese method handle:              cache retrieving and/...
API: The processCache() method !It can be used for custom developements too !It will let you implement caching in your own...
API: The processCache() method, CODE !1.$cacheFilePath = eZCachedModule::cacheFilePath( $Params );2.$cacheFile = eZCluster...
API: The processCache() method, callbackLets review an example that caches the whole output($Result) of a module.It has a ...
API: The processCache() method, callback1. Enable the DebugOutput  Come on, you know how to do it2. Go to http://ezpublish...
API: The processCache() method, callbackLets review an example that caches the whole output($Result) of a module.It has a ...
eZ Publish cluster unleashed revisited
Upcoming SlideShare
Loading in …5
×

eZ Publish cluster unleashed revisited

1,754 views

Published on

Revisited versio

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,754
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

eZ Publish cluster unleashed revisited

  1. 1. eZ Cluster unleashedThe return
  2. 2. Purpose and historyOne eZ Publish on multiple servers, for:PerformanceRedundancyCreated for eZ Publish 3.8, vastly improved since then:3.10: huge schema & feature improvements4.2: new eZDFS cluster handler for NFS4.2: Stalecaching mechanism for eZDB and eZDFS4.7: Refactored binary index architectureMatches the shared database for filesystem operations:Inserting new data, expiring/deleting obsolete dataserving files through HTTP
  3. 3. Cluster handlers eZ DB eZ DFSFrom eZ Publish 3.8 From eZ Publish 4.2Stores metadata in DB Stores metadata in DBStores data in DB (BLOBs) Stores data on NFSEasy to setup Requires an NFS serverHuge DB, harder to maintain Maintenance is much easier
  4. 4. HTTP vs Internal callsHTTPRequests done through index_cluster.phpServes files directlyA reverse proxy caches images & binary filesINTERNAL / KERNEL CALLSReads/writes cache itemsStores binary files
  5. 5. Configuration #1: file.iniA cluster handler must be configured in a file.ini override:1.[ClusteringSettings]2.FileHandler=eZDFSFileHandler1.# DFS Cluster Handler settings2.[eZDFSClusteringSettings]3.MountPointPath=var/nfs4.DBBackend=eZDFSFileHandlerMySQLBackend5.DBHost=localhost6.DBName=labs_ezpublish_trunk_cluster7.DBUser=root8.DBPassword=root
  6. 6. Configuration #2: databaseeZDB and eZDFS both require database tablesThe same DB server can be usedPerformance wise it is better to use another serverSchemas are available inkernel/sql/*/cluster_*_schema.sql (mysql only, oracles are inthe extension)
  7. 7. Configuration #3: clusterizeExisting local files must be moved to the clusterThis  is done using bin/php/clusterize.phpThis script will copy/move images & binary files from the localfilesystem to the clusterIt must only be executed once for the whole cluster
  8. 8. Configuration #4: binary URLs rewritingURL rewriting is required to "stream" clusterized binary files tovisitors: Images Binary filesThey only affect known path for these types of filesTo stream different files, new rules must be added RewriteEngine On Rewriterule ^/var/([^/]+/)?storage/original/.* /index_cluster.php [L] Rewriterule ^/var/([^/]+/)?storage/images/.* /index_cluster.php [L] # Standard eZ Publish rewrite rules # ...
  9. 9. Configuration #5: binary files indexThe cluster index handles binary files HTTP requestsIt doesnt use the whole kernel in order to perform betterIt was completely refactored in 4.7Before 4.7 After 4.7Required custom file to be created No custom filesMany files also located at root level DocumentedDuplicated logic among handlers Common code has been refactoredFeatures werent identical among Features are (almost) perfectly
  10. 10. Configuration #5: binary files index, example/** * Cluster configuration file */define( CLUSTER_STORAGE_BACKEND, dfsmysqli );define( CLUSTER_STORAGE_HOST, localhost );define( CLUSTER_STORAGE_PORT, 3306 );define( CLUSTER_STORAGE_USER, clusteruser );define( CLUSTER_STORAGE_PASS, );define( CLUSTER_STORAGE_DB, ezcluster );define( CLUSTER_STORAGE_CHARSET, utf8 );define( CLUSTER_MOUNT_POINT_PATH, /opt/nfs/ez );
  11. 11. How cache is handledRemote, clusterized files are copied locallyBefore using a local file, eZ always checks if it is newerthan the remote oneWhen a cache file is generated, it is stored on the cluster,and re-used by other nodesexpiry.php provides an intermediate method
  12. 12. API: reading clusterized files1.$path = /var/ezwebin_site/path/to/my/file.txt1.// read a text file, "instance" syntax2.$contents = eZClusterFileHandler::instance( $path )->fetchContents();1.// read a text file, "static" syntax2.$contents = eZClusterFileHandler::instance()->fileFetchContents( $path );1.// fetch a file (a binary one for example) to disk2.$path = var/ezflow_site/storage/original/video/961d8a65efffdd93708cc23bc6398953.flv;3.$handler = eZClusterFileHandler::instance( $path )->fetchUnique();1.// ... use the file ... then delete it2.$handler->deleteLocal( $uniquePath );1.// reading metadata2.$file = eZClusterFileHandler::instance( $someFile );3.echo $file->size();4.echo $file->mtime();
  13. 13. API: writing a file to the clusterAgain, the native PHP I/O API isnt cluster aware !1.// stores the contents of the $contents variable to cluster2.$path = var/ezwebin_site/file.txt;3.$handler = eZClusterFileHandler::instance( $path );4.$handler->storeContents( $contents, text, text/plain );1.// alternative "static" method: fileStoreContents()1.// stores the contents of a local image as a clusterized file2.$imagePath = var/ezwebin_site/path/image.png;3.$handler = eZClusterFileHandler::instance();4.$handler->fileStore( $imagePath, image, true, image/png );
  14. 14. API: ViewCache !ViewCache uses advanced methods of the cluster APIThese method handle:  cache retrieving and/or generation  Concurrency  stale cachingIt can technically be used to manage custom cache !Next: introducing the processCache() method
  15. 15. API: The processCache() method !It can be used for custom developements too !It will let you implement caching in your own extensionsIt uses:  a generate() callback that generates the dynamic content  a retrieve() callback that retrieves valid cached content
  16. 16. API: The processCache() method, CODE !1.$cacheFilePath = eZCachedModule::cacheFilePath( $Params );2.$cacheFile = eZClusterFileHandler::instance( $cacheFilePath );3.$Result = $cacheFile->processCache(4. array( eZCachedModule, retrieve ),5. array( eZCachedModule, generate ),6. null,7. null,8. compact( Params ) );1.return $Result;
  17. 17. API: The processCache() method, callbackLets review an example that caches the whole output($Result) of a module.It has a configurable TTL, and provides a custom cache keythat can be used to invalidate cache.1. Get the code from github:git clone git://gist.github.com/3635993.git extension/ezcachedmodule2. enable the extension in site.iniActiveExtensions[]=ezcachedmodule3. and do not forget to regenerate the extensions autoload:Php bin/php/ezpgenerateautoloads.php –extension
  18. 18. API: The processCache() method, callback1. Enable the DebugOutput Come on, you know how to do it2. Go to http://ezpublish4.admin/cachedmodule/view/abcd Look into the debugOutput for « eZCachedModule »3. Lets review it together
  19. 19. API: The processCache() method, callbackLets review an example that caches the whole output($Result) of a module.It has a configurable TTL, and provides a custom cache keythat can be used to invalidate cache.1. Get the code from github:git clone git://gist.github.com/3635993.git extension/ezcachedmodule2. enable the extension in site.iniActiveExtensions[]=ezcachedmodule3. and do not forget to regenerate the extensions autoload:Php bin/php/ezpgenerateautoloads.php –extension

×