13

pantheon.io is a managed hosting service & devops infrastructure with support for Drupal and WordPress.

  • What additional considerations are there for hosting CiviCRM on Pantheon?
  • Are there any specific configurations or patches required?
  • Is there any functionality which differs from hosting CiviCRM on a "standard" LAMP stack?
11

There are two approaches, use the CiviCRM Starterkit which currently is available as an upstream for Pantheon, or use a fresh CiviCRM install with some patches.

CiviCRM Starterkit

The starterkit is a Drupal distribution will get you most of the way since it includes a few patches so CiviCRM will work more smoothly on Pantheon's architecture. In order to use the the starterkit in Pantheon use the option provided when creating a new site from the Pantheon dashboard (and not from the distribution hosted on drupal.org). Unfortunately, the original maintainer is no longer working on CiviCRM projects so has been unable to maintain the distribution.

CiviCRM with patches

The other approach is to install CiviCRM manually on top of the default Pantheon upstream for Drupal and apply the patches from the Starterkit which patch CiviCRM core. One can then maintain the appropriate patches so they can be applied to each CiviCRM upgrade, similar to the repo "CiviCRM for Drupal on Pantheon" we've maintained for a client (though there are differences currently in what people are patching).

Dealing with a dynamic system

The main change required for CiviCRM to work with Pantheon is get around CiviCRM's approach of hardcoding the absolute paths to all its configuration. Pantheon (and other similar hosts) use environment variables to set the server paths and the database connections. That's because its app bindings will change depending on whether the fallback server kicks in to deal with the load on the site. I've found that this can happen often, especially when a large mailing is being sent out.

First the paths and database connections are set up dynamically in civicrm.settings.php (as described in Kalamuna's post and patched in the Starterkit and the alternative patches). Then one needs to deal with CiviCRM's caching of absolute server paths (at least up to 4.7). For now one can simply bypass the caching of configuration entirely with no discernible downside.

Using Redis for caching and template storage

Pantheon uses Redis caching to improve the handling of the Drupal cache (Redis can handle it better than MySQL). In order to get CiviCRM to also use Redis caching as the default for CiviCRM cache one needs to set up a new Redis caching class in CiviCRM and set it as the default in civicrm.settings.php. This has been merged into CiviCRM core for 4.7. (based on this git repo).

To use Redis for storing the compiled Smarty templates follow the approach outlined in this forum post, which for some has made noticeable improvements to the speed at which CiviCRM loads templates in Pantheon. It can be done by either using Drupal caching functionality cache_get and cache_set or with CiviCRM to store cache in Redis (patch). You may notice some side-effects with using scripts in extern/* folder that don't bootstrap the CMS, so you may find these patches.1 2 useful (for PaypalPro).

There are a few other minor patches as part of the Starterkit but these main ones will get you a long way to a stable and efficient CiviCRM on Pantheon.

Cron

By default Pantheon runs cron once an hour. In order to run cron more often, which is useful for more granular control of CiviCRM cronjobs (also useful for Drupal's Elysia cron), one needs to use an external cron or ping service.

Emails and SMTP

For basic Drupal setups on Pantheon just using their email service for sending basic transactional emails is okay. But it is highly recommended to use an external SMTP service for emails on CiviCRM (and for Drupal). CiviSMTP and Mandrill (with a CiviCRM extension) will work for Civimail and CiviCRM transactional emails.

Benefits of CiviCRM on Pantheon

As others have noted, being able to quickly clone the site into a new branch with MultiDev, or even just clone between the default environments, can be a big time saver for small development firms and for freelancers without the knowledge or support of building a similar system.

  • 1
    I've tried to be more comprehensive here about what is required to get CiviCRM to run on Pantheon. I can edit anything incorrect or missing. – herb Aug 6 '15 at 14:54
  • Best answer so far, covers all the points I have. – Owen Kelly Aug 6 '15 at 23:01
  • can you link to the issues where you've mentioned them being worked on in core? – ryancross Aug 7 '15 at 1:31
  • also, i think its worth clarifying that the civicrm_startkit on its own is not suited for Pantheon. There is a pantheon specific version for the starterkit – ryancross Aug 7 '15 at 1:33
  • 1
    Although obviously I have opinions about whether Pantheon is worth it overall, this is a really nice outline of what should be done in order to make it work. – Andrew Hunt Aug 7 '15 at 3:19
4

There are a few gotchas (and probably some I haven't run into). I moved one of my clients with about 40,000 contacts to Pantheon (business level plan) in October, and we've had pretty good success with it after ironing out a few major details.

The biggest problem is Smarty. Since it compiles its templates into the file system (Valhalla), they tend to run slower than molasses in January in Siberia. The solution can be found here:

https://forum.civicrm.org/index.php?topic=35125.0;nowap

The basic premise here is that loading compiled templates from Redis is going to be much, much faster than loading them from the file system. The thing you'll need to watch for with this is anything that uses Smarty now needs to bootstrap Drupal to have access to cache_set and cache_get for Redis. In general, you should keep anything PHP based (extensions, core file overrides, etc) in sites/all/something, not sites/default/files/...

The second biggest thing we ran into was a problem with accessing extensions on business level and above plans (since they run multiple appservers). For some reason Civi likes to cache paths, so I had to write some custom code into the extension loader to account for that (and pop it back to the right path when it gets off track).

The final big piece you'll need is Kalamuna's civicrm.settings.php modifications, which can be found here: http://blog.kalamuna.com/news/civicrm-pantheon

They're meant for D6, but I've found they work just fine with D7 (and you can go a step beyond and do the same path overrides for everything they don't, such as extensions).

I can tell you from my experience, which started about a year ago, there are some headaches that come along with this, but the benefits of MultiDev and the security of not having to worry about the platform (at least for me) are worth it in the long run. This has sped up our development cycle significantly, and the reliability and lack of late evening trouble calls have been worth it. We've been running 4.4.x since January, and the number of headaches I've had that are platform related have been steadily dropping once you get through the first big problem above (Smarty).

  • Thanks Chris. Would you unpack this statement for me a bit more? The thing you'll need to watch for with this is anything that uses Smarty now needs to bootstrap Drupal to have access to cache_set and cache_get for Redis. In general, you should keep anything PHP based (extensions, core file overrides, etc) in sites/all/something, not sites/default/files/... - you mean the contents of templates_c/* when you are saying "PHP based", or is that two separate statements? – Chris Burgess Aug 6 '15 at 2:40
  • 1
    The second biggest thing we ran into was a problem with accessing extensions on business level and above plans (since they run multiple appservers). For some reason Civi likes to cache paths, so I had to write some custom code into the extension loader to account for that (and pop it back to the right path when it gets off track). - I'd be happy to help get this in if you're keen to see it part of core. Want to open an issue on it @ issues.civicrm.org ? The hardcoded path fixity is something I'd love to see gone from CiviCRM. – Chris Burgess Aug 6 '15 at 2:42
  • There is already an issue for this: issues.civicrm.org/jira/browse/CRM-16618 -- looks like its going nowhere without funding and/or patches. – herb Aug 6 '15 at 13:44
  • Is Redis the only way aroung the Smarty issue? Redis is only available on the enterprise plan which is $75/month more than the personal plan that we are on. – Yossi Dec 1 '15 at 4:58
  • Regarding CiviCRM caching config, this issue changes they way Civi deals with config in 4.7: issues.civicrm.org/jira/browse/CRM-16373. Hopefully this will address the one concern about full paths getting cached. – herb Dec 6 '15 at 15:08
3

Patheon also does not provide an ability to tune your database. Its database configuration is more tuned for CMS's like Drupal and Wordpress, and not for CRM's like CiviCRM which can have huge data storage requirements.

Another aspect which I have difficulty with (though ultimately it doesn't matter too much) is the need to maintain the entire Drupal/Wordpress and CiviCRM codebase in Git. It just seems like such a waste when the core files are readily available elsewhere. But again, that's just a personal nit.

2
  1. A bottle of aspirin
  2. A lot of patience
  3. A budget to migrate the site to another host

I actually can't remember all the issues, but I know that Tommy and Sanjay have had continual trouble with folks on Pantheon. There have been problems running upgrades on their dev sites because they're underpowered. Pantheon doesn't provide any cron except a drush cron every hour, so you have to have another server run cron for you if you want a decent frequency. There have been other issues that don't immediately come to mind, but I have yet to see any advantage to using Pantheon.

Fundamentally, it's just overpriced, gussied-up shared hosting. Anyone will do better with a VPS and their dev/staging/production sites set up in regular git repos.

  • This isn't a very balanced response. There are pros and cons to using Pantheon I've found. Since Pantheon focuses on Drupal and Wordpress officially it's not that fair to blame them for not working all the time with CiviCRM. – herb Aug 6 '15 at 2:40
  • Oh, they'll change file paths on alternate Tuesdays, except when Mercury is in retrograde, when it's each Friday. They also make no promises regarding your mail IP address, so you have to do external SMTP or you get to have fun configuring SPF for a moving target. – Andrew Hunt Aug 6 '15 at 2:44
  • @herb no, you're right that it's not balanced. I don't think it's necessarily bad for what it is; I just know that what it is isn't good for CiviCRM. – Andrew Hunt Aug 6 '15 at 2:46
  • Yes Pantheon changes its bindings for load balancing, but that's something that Drupal or Wordpress have no problem handling. So it means that out of the box CiviCRM doesn't account for that, but I've found small changes make it work. Regarding external SMTP this is something we always do on our own servers as well. SMTP services do a much better job anyway. – herb Aug 6 '15 at 15:28
  • @herb totally agree on SMTP in general, but for someone not using CiviMail, it can be overkill for just receipts and password reminders here and there. My main feeling is that just because you can make it work doesn't mean it's worth the trouble when there are plenty of perfectly good hosting arrangements that don't require these workarounds. – Andrew Hunt Aug 6 '15 at 16:13
2

We have a few sites on pantheon running civicrm. We started with the civicrm_starterkit. There were a few issues to iron out but Pantheon does save you the headache of worrying about hosting, and multi-dev environment goes a long way. Also with the kalabox from kalamuna, local development for pantheon sites is life changing.

We updated the starterkit's civicrm 4.4 to 4.6 without any issues.

2

I'm currently testing a CiviCRM extension which regenerates cache (updates the file paths) when they change on Pantheon.

What is the best way to override changes to CRM_Core_Config?

It's a CiviCRM extension, which I'm happy to share if it works as expected.

  • I suspect this question on Pantheon Power-Users (membership required to view) may be looking for the solution your CacheOff extension offers - would you consider publishing it for them? Shouldn't hurt for you to have more people testing it :) – Chris Burgess Jan 13 '16 at 21:27
1

Made this module for Drupal, which flushes the CiviCRM cache when the disk path changes:

https://github.com/adam-devapp/drupal-pantheon-civicrm-cache-clear/tree/master/civicrm_cache_clear

The path is cached, so there is only the initial database call. If you're site switches servers a lot, it may cause some slowness whilst the cache is regenerated, but works well for my needs and hands off.

The alternative was to submit a path to Smarty to support Redis template caching (smarty), as to stop hacking third party libraries. Currently, the only way to add Redis caching to smarty, is to hack smarty distributed with CiviCRM.

  • can the lack of this module be what is causing me to often get this error when accessing civicrm pages : "The xml data cannot be loaded" – Yossi Mar 27 '17 at 22:46
  • Yes, I believe so. The error goes away after a page refresh (as the file is regenerated). Since using this module, the issues with Pantheon have gone away completely. – Adam Mar 28 '17 at 2:51
  • I've enabled this module on many sites and the error "The xml data cannot be loaded" continues to persist. any ideas? – Yossi Dec 4 '17 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.