Apache 2.4, Varnish and RelStorage

I'd like to change my setup and at last switch to RelStorage (currently FileStorage) and use Varnish for caching and load balancing.

Currently I have an Apache 2.4 server and two macros (for http and https) which create a VirtualHost including the usual RewriteRule for the VirtualHostMonster; it as well uses files in a per-instance directory to load additional redirections from files, which makes my Apache vhosts configuration file look like this:

Include conf/snippets/vhost-macros.inc
# 3rd argument is a fs subdirectory name
# 4th argument is the Zope port (of course)
# 5th argument is the ZODB-internal path of the Plone instance
Use PloneHost80  123.234.56.78 www.my-domain.com my-domain 8080 Plone
Use PloneHost80  123.234.56.78 www.my-domain.de  my-domain 8080 Plone
Use PloneHost443 123.234.56.78 www.my-domain.com my-domain 8080 Plone
Use PloneHost443 123.234.56.78 www.my-domain.de  my-domain 8080 Plone
# (other macro uses for other virtual hosts, e.g. for development or testing)
Include conf/snippets/vhost-macros-undef.inc

My current idea is

  • to let Apache handle the TLS issue, so it would remain in front
  • instead of talking to Zope directly, Apache would talk to Varnish
  • Varnish would talk to two (or more, perhaps) Zope instances and handle the load balancing.
  • The Zope instances would talk to the local PostgreSQL server to access the ZODB (RelStorage)

Does this sound reasonable?

More considerations:

  • The Apache configuration can be reloaded safely and extremely quickly (e.g. when a new file is needed to add a redirection), so I'd like to keep the rewriting there
  • Currently I still have PostgreSQL 9.3. and some sort of Plone 4.3 (ZODB 3.10.5, psycopg2 2.5.5). I couldn't find any hint for the RelStorage version in the KGS for any Plone 4.3 version. Should I stick with RelStorage 1.6.3, or is it safe to use 2.0.0 in production?
  • My sites are multilingual and language-switchable (with some paths valid for both languages and providing different contents), so this would need to be supported.

Your "current idea" is what I would do but using Nginx (in fact it does not matter much which one).

Your "more considerations":
Point 1: thats right
Point 2: With Plone 4.3 use latest RelStorage 1.6.x release. 2.x is not safe.
Point 3: plone.app.multilingual supports it. Partial translations result in partial content trees, there is no fallback by default. Assets like files and images can be uploaded to a neutral folder. There are some poorly maintained addons with all its own limitations to overcome this. Anyway, since there is no common use case, so there not THE way to handle the case.

Thanks for your answer. So I'll stick with RelStorage 1.6.3.

Unfortunately, I don't have language-specific subtrees, so the language is controlled by some cookie,
and my Varnish setup might need thorough testing.
I might change this one day ...

For varnish you can try if plone.recipe.varnish for buildout may help you.

@tobiasherp

I have created a repository with some configurations for frontend consisting of NGINX> Varnish> HAPROXY> Zope> Relstorage

Feel free to use it as a reference!

Hugs