Drupal and CQRS/ES (Command Query Responsibility Segregation and Event Sourcing)

Submitted by dryer on Sat, 09/17/2016 - 08:10
Drupal performance

Drupal is a very popular content management framework that is used for all kinds applications. With global web applications and sites relying on Drupal, performance is one question that is often pops up. Most of the performance techniques for scaling out Drupal have to do with optimising the infrastructure.

For read performance additions high performance Java-based solutions like Elastic search and Drupal are used to improve performance. These advantage technologies offer superior performance for querying data over the baseline PHP and MySQL solutions that Drupal is founded on.

Where scaling becomes hard is scaling for write solutions. With Drupal 8 being slower than Drupal 7 there is no help from upgrading to the latest version. Logged in users that are allowed to interact with the Drupal content storage can easily become the bottle net in complex Drupal architectures.

Should I scale Drupal with CQRS/ES?

One solution that the PHP world is adopting from higher performance environments like .NET and Java are two things are:

  • Command Query Responsibility Segregation (CQRS)
  • Event Sourcing (ES)

These are mechanisms that enable high performance for applications that need to read an write data. CQRS means that your read and write models become separate. Instead of interacting directly with the underlying datamodel, you will collect mutations on content using Event Sourcing (ES). This means that the events are collected very fast.

For reads the Drupal data source is then mutated later by an asynchronous process. Alternatively your could also transform cached Drupal content using the event database. The CQRS/ES pattern does not define exactly how this will be done.

All of the means that there will a significant amount of complexity when using Drupal with CQRS/ES and in fact the value of using Drupal at all. Drupal is a content management system and many times collecting a lot of data and serving devices in IoT (Internet of Things) scenarios and so on, might actually diminish the value of using Drupal at all.

So as a bottom line it's safe to say that if you are considering using Drupal together with Command Query Responsibility Segregation and Event Sourcing techniques... You might actually be better off using a completely different solution altogether.