|
|
||||||||||||||||||
|
|
||||||||||||||||||
![]() |
![]() |
Issue 7 - Revision 7 / May 19, 2004
|
|||
|
Zope sites and ZEO - An Introduction - - - - - - - - - - - - By Bakhtiar A Hamid | January 23, 2004 Abstract Slow or unresponsive Web sites turn users off. Therefore it is imperative that site owners take necessary measures to scale their sites. With Zope, this is easy. Use Zope Enterprise Object, or ZEO for short – with an unresponsive site just add a Unix box, install ZEO Client and the rest is taken care of by ZEO. ZEO is also useful as a development tool and as a means of accessing Zope sites from the command line, which is very convenient. IntroductionWhat is ZEO? When we run stock Zope, only one Zope instance can access the Zope Object Database (ZODB) which is usually a FileStorage instance named Data.fs. ZEO changes this behavior. With ZEO, many Zope instances (ZEO Clients, ZC) can access the database (ZEO Storage Server). Thus, we may have many different servers each running a Zope instance that acts as a ZEO Client, even with each box running more than one ZEO Client. These ZEO Clients then access the ZEO Storage Server for data. See Diagram 1. ZEO is a client and server system, with ZEO Storage Server (ZSS) serving a consistent database to all ZEO Clients (usually Zope instances). In addition, ZEO implements a temporary or persistent on-disk cache that caches recently used objects, speeding up requests. The caches can also be used if the ZEO Storage Server dies. Changes in a ZEO Client are propagated to the ZSS. The ZSS invalidates outdated data in caches in other ZCs, thus synchronizing the data between ZCs. Theory of operationA ZEO Storage Server needs to serve the database. Zeo Client will check its cache (if persistent cache is configured – if persistent cache is not selected the default setting is temporary cache) and verify it with the ZSS when it connects. Every client disconnect or crash results in validation when one restarts. Zope checks the index of file 0 and file 1 (the two cache files ZEO sets up – see the next paragraph), verifies the data with the server, invalidating data that is outdated. Each ZC that is configured to use persistent cache will keep two cache files in the instance's home var directory. The files use the following convention c If a ZSS serves out data using a public IP address, any Tom, Dick or Harry can connect and serve the data too (a ZC is a server to the end user, a client to the ZSS), unless an authentication scheme (based on HTTP digest authentication) is used. A more secure way is to run ZSS and ZCs in a private network, or run through a Virtual Private Network for servers that run in different geographical locations.. InstallationTo install ZEO successfully, one needs to have a running Zope instance. This article describes installation for Zope 2.7 on a Unix box. Binary installation may differ in the path to the file, but the theory of operation is still the same. Installing ZopeGet the Zope tarball from http://www.zope.org/Products. To make things easier, we will use the following terminology:
Installation steps: For a successful installation, it is advised that the installation be done by the user who will run the Zope instance. In this example, we'll be using the username zopeuser.
If everything is in order, we are now ready to install and run ZEO. Installing ZEOIn previous Zope versions, ZEO was not included in the Zope tar ball. To run ZEO, we had to get the necessary tar ball (initially, ZEO was distributed as a tar ball). Then, to use ZEO it was necessary to extract it from the ZODB; which sometimes confused users. As of Zope2.7, users no longer need to worry since ZEO is bundled with core Zope. ZEO installation is not complex. Change to the zope top-level binary directory and run mkzeoinstance.py /usr/local/zope27$bin/mkzeoinstance /path/to/zope/instance 8800 The necessary files will be copied to the Zope instance directory. Note that the zeo.conf file is for ZSS configuration. Client configuration is done in zope.conf Installing the ZEO Storage ServerThe default zeo.conf is as follows:
# ZEO configuration file
%define INSTANCE /usr/local/zope
</folder>
<zeo>
address localhost:8800
read-only false
invalidation-queue-size 100
#monitor-address PORT
# transaction-timeout SECONDS
</zeo>
<filestorage 1>
path $INSTANCE/var/Data.fs
</filestorage>
<eventlog>
level info
<logfile>
path $INSTANCE/log/zeo.log
</logfile>
</eventlog>
<runner>
program $INSTANCE/bin/runzeo
socket-name $INSTANCE/etc/zeo.zdsock
daemon true
forever false
backoff-limit 10
exit-codes 0, 2
directory $INSTANCE
default-to-interactive true
# user zope
python /usr/bin/python
zdrun /home/kdie/zope27/lib/python/zdaemon/zdrun.py
# This logfile should match the one in the zeo.conf file.
# It is used by zdctl's logtail command, zdrun/zdctl doesn't write it.
logfile $INSTANCE/log/zeo.log
</runner>
Some of the storage options that can be changed:
Once everything is set, we can test the ZSS by running /path/to/zope/instance/bin/runzeo runzeo runs in the foreground and only stops with a Ctrl-Break. Installing the ZEO ClientTo have a working ZEO Client, edit zope.conf and add the following:
# Temporary storage:
<zodb_db temporary>
<temporarystorage>
name sessions
</temporarystorage>
mount-point /temp_folder
container-class Products.TemporaryFolder.TemporaryContainer
</zodb_db>
#
# ZEO client storage:
<zodb_db main>
mount-point /
<zeoclient>
server localhost:8800
storage 1
name zeostorage
client local
cache-size 102400
var $INSTANCE/var
</zeoclient>
</zodb_db>
With this setup, we will have a ZEO Client that uses a persistent cache of 100MB connecting to storage 1 of the ZSS. The ZEO Client comes with some configurable parameters. Some of these parameters are:
To add more ZEO clients, install Zope as required, test the Zope instance and repeat the “Installing ZEO client” steps. Testing the ZEO clientTo test the zeo client, run /usr/local/zope$bin/runzope Some debugging notice will fly by, and everything should be ok once we get: 2003-12-14T23:29:08 INFO(0) Zope Ready to handle requestsVerifying our setup There are a few ways to verify that ZEO and Zope are running. The easiest way is to check the log files. By default, zeo.log is used to record all ZSS messages. Checking the contents of zeo.log will determine the success or failure of starting ZSS.. $tail /usr/local/zope/log/zeo.log ------ 2003-12-15T14:26:34 INFO(0) RUNSVR opening storage '1' using FileStorage ------ To confirm that our ZEO client is working, check out the contents of the event.log: /usr/local/zope$tail var/event.log ------Finalizing the ZSS/ZEO installation Now that everything is running as expected, we should use zopectl and zeoctl to start and stop the ZSS and the ZEO client. Starting ZSS with zeoctl /usr/local/zope$bin/zeoctl start Starting the ZEO client with zopectl /usr/local/zope$bin/zopectl start Now we can check the status using zeoctl and zopectl /usr/local/zope$bin/zeoctl status program running; pid=2349 /usr/local/zope$ bin/zopectl status program running; pid=2353Balancing act There are many ways we can balance the requests to the Web sites once the cluster comprising the ZSS and ZEO clients is operational. Some of the many ways to load balance the cluster:
One great benefit of running Zope with ZEO is the ability to debug and access Zope interactively. For example, we may resolve Zope Management Interface lockup using such a method. Accessing Zope interactively also makes certain automatic operations, such as packing or backing up the database, much easier. Debugging steps with ZEO
Zope 2.7 comes with batteries included. With ZEO, we can scale sites easily by chucking in more processing power. ZEO also makes debugging and automating Zope easier. ReferencesThis basic example was kept very simple, covering the basic goals:
The details to accomplish these goals: Zope Book - Scalability and ZEO http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZEO.stx
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| ZopeMag is committed to bringing you the best in Zope Documentation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
Reproduction of material from any of ZopeMag's pages without prior written permission is strictly prohibited. Copyright 2003 - 2005 ZopeMag |
|