Subrequests as another speed secret for Drupal 8

Subrequests as another speed secret for Drupal 8

The unmatched capabilities to interact with other systems is listed among Drupal 8’s best improvements (along with the Views and BigPipe in core, easier migrations, handier configuration management, excellent web accessibility, and much more). And there are various ways to provide great performance in this interaction. One of them is the new and fresh module called Subrequests. We will briefly get acquainted with the Subrequests’ principle of work and features for speed enhancement today.

Drupal 8 and third-party integration

Let’s first take a glance at your Drupal 8 site’s ability to share its data to any external systems you need. These can be native mobile applications on Android or iOs, super dynamic JavaScript apps (based on Angular, React, Node, Ember, Backbone, etc.), or any other third-party systems.

Among other things, this lets you use the trending “headless”, or “decoupled” approach, when Drupal serves as a back-end and outputs its data to some front-end system for the sake of exceptional speed, interactivity, real-time features, and more.

The key thing here is to present Drupal’s HTML data in the formats needed by these applications (JSON, XML, or HAL+JSON). Just like good interpreters help people who speak different languages, there are high-class “synchronous interpreters” between Drupal and third-party apps.

These great assistants transform the data into the required formats. The Drupal core now has a “team” of these built-in. These are web services: Serialization, HAL, RESTful Web services, and HTTP Basic Authentication.

In addition, there also are great contributed modules, one of which we will present right now.

Subrequests module and its performance-improving mission

How to help the “synchronous translation” work exceptionally fast? Here is where the Subrequests module comes in.

The Subrequests module groups any sets of requests together, with absolutely no limitations. Thanks to this aggregation, all JSON API requests are sent in just one. The absence of round-trips for fetching Drupal’s data greatly improves performance. Drupal bootstrap is only needed once.

The single request contains all the information that the app needs from Drupal. It’s kept in a JSON document called “blueprint.” The blueprint lists multiple subrequest objects.

The Subrequests module allows for very handy options like sending parallel requests, sending requests that depend on the response to previous request, and more.

Installing the Subrequests Drupal 8 module

This module did not exist in Drupal 7. Subrequests are a true novelty of Drupal 8, with its 8.x-2.0-beta3 released just a month ago.

For efficient work, the module needs some external PHP libraries. So to install the Subrequests module with all these libraries, you could use this Composer command:

composer require drupal/subrequests:^2.0

More technical details along with the code samples can be found in the article of the module’s maintainers, Lullabot, and on the module’s page.


To get the best of the Subrequests Drupal 8 module, create custom solutions for your website’s great performance and handy integration, or migrate to Drupal 8, contact InternetDevels developers. Get more news from our newsletter and on our social media pages!

1 vote, Rating: 5

Read also


Website administrators love it, Drupal newbies start with it, and Drupal ninjas perform miracles with it. The Views “inside Drupal” is listed among...


Using the Superfish Drupal module, which integrates the jQuery Superfish menu plugin, you can create interactive multi-level menus with exceptional...


Every six months, there comes a fresh Drupal 8 minor release full of lucrative features. And another big day has come! Drupal 8.4.0 is out on October 4, making this autumn especially rich in gifts...


Drupal 8’s “fruitful fields” of opportunities are endless — so let’s take another walk through them! Along with everything else, Drupal 8 also lets you create custom field formatters...

Need a quote? Let's discuss the project

Are you looking for someone to help you with your Drupal Web Development needs? Let’s get in touch and discuss the requirements of your project. We would love to hear from you.

Join the people who have already subscribed!

Want to be aware of important and interesting things happening? We will inform you about new blog posts on Drupal development, design, QA testing and more, as well news about Drupal events.

No charge. Unsubscribe anytime