I have learned something new. So I want to share it.

Suppose you have a ZEO client and 2 ZEO servers. Is it possible to configure the ZEO client that if the first ZEO server crashes it uses the second ?

The answer is yes with one condition: the 2 ZEO servers MUST share the same storage (Data.fs) OR the 2 storages MUST be identical (perfect replication).

SETUP (tried only with Zope 2.9.6):

1. Create a ZEO client (mkzopeinstance.py)
2. Create 2 ZEO servers (mkzeoinstance.py)
3. change the ports on which the servers listen. Lets say port 8881 for the first server and 8882 for the second
4. start the first server
5. make a symbolic link to the Data.fs of the first server in the 'var' folder of the second server
6. start the second server
7. edit the client's zope.conf and comment these lines:
 #<zodb_db main>
# # Main FileStorage database
# <filestorage>
# path $INSTANCE/var/Data.fs
# </filestorage>
# mount-point /
#</zodb_db>

and add the 2 servers in the zodb_db main tag:
 <zodb_db main>
mount-point /
<zeoclient>
server localhost:8882
server localhost:8881

storage 1
name zeostorage
var $INSTANCE/var
</zeoclient>
</zodb_db>

8. Set debug to on in the zope.conf and start the ZEO client with runzope so that you can see what's going on.

Now the ZEO client will use the server at 8881 as its storage. Try to stop the first server and see the output in the terminal where you executed the runzope command. The ZEO client will connect to the second server at 8882. start the first server again and stop the second. You will see that the client will connect back to the first server.

I don't know the side effects of such setup. So don't use it in production.

Have you tried this setup before ? Share you experience: drop a comment.