I have a web site where I have one machine running 12 Zope instances. In my buildout.cfg.
What is bothering me is that almost every time I run bin/buildout the instance parts are updated, and this process is quite slow. It is is slow for the first instance and takes the same time for each of the remaining instances.
Is there anything I can do to minimize buildout time? Do you suffer of long buildout times as well ?
buildout will remove and recreate all the parts in your buildout.cfg so it will do so to each instance*
Is there a reason why you need buildout to run more quickly?
If it's because you're running buildout on your production (live) server, you should know that it doesn't usually affect running processes; they'll keep running.
A colleague is using a single "buildout" "instance" for multiple Zope instances. It essentially works like this:
each of the Zope instances has its own "folder" which is a symbolic link to the common Zope folder. The name of this instance folder contains an instance identifying instance number.
A Zope instance is controlled (i.e. start|stop|restarted) by a specialized shell script. This determines the instance number, derives from it instance differencing parameters (such as port and logfile) and then activates the normal instance controlling program (e.g. bin/client1) with these parameters (overriding corresponding definitions in zope.conf).
The controlling shell script is assumed to be always started from the instance folder (giving it a means to determine the instance number from the folder is has been started from).
Upgrade ZConfig to at least 3.1.0
Check the docs for ZConfig, it allows you to use environment variables, for example for the http-address.
Then you can build one instance and set the env variable in supervisor.
We are using this for quite some time already.
I"ll try that. The provided workarounds presented here are very clever, but I suspect that once the first instance is built then some things could be cached for the next instances. Perhaps at the level of the zope2instance recipe.
However the advice to use env variables instead is the best solution. For each instance you really are using buildout change the instancename, path, fs location and port. Thats overkill.
@djay is right. I did some quick profiling and most of the time taken to build/update an instance is spent creating the "working set" i.e the set of Python distributions available to the Zope instance.
I think caching the working sets makes sense, regardless of the existence of the environment variables approach.
So I made a PR to zc.buildout and would be very glad if you help to review and/or test it. If you have buildouts with many instances you'll experience an N-fold speedup without changing anything in the config files . @hvelarde, @idgserpro, @tkimnguyen
It's been fun! Another Brazilian, @leorochael is reviewing the PR. It seems the quality assurance in order to get code into zc.buildout is quite high. Which is reassuring because it's such an important piece of software.