Categories

(83)
(69)
(8)
(34)
(74)
(149)

Subrequests as another speed secret for Drupal 8

21.11.2017
Subrequests as another speed secret for Drupal 8
Author:

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 the 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 drupal.org page.

Wrap-up

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 Drupal developers. Get more news from our newsletter and on our social media pages!

2 votes, Rating: 5

Read also

1

The magic ability of images to adjust themselves to screens is how responsive web design works. And it works especially well in the latest Drupal version, Drupal 8, which has built-in support for...

2

Website administrators love it, Drupal newbies start with it, and Drupal ninjas perform miracles with it. The Views “inside Drupal” is listed among Drupal 8’s best improvements. Let’s discover a...

3

Using the Superfish Drupal module, which integrates the jQuery Superfish menu plugin, you can create interactive multi-level menus with exceptional usability features. Let’s see how it works on...

4

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...

5

We have a confession to make. Frankly, we’re becoming kind of shopaholics ;) After the release of Drupal Commerce 2.0, our passion for discussing and building cool Drupal 8 online stores keeps...

Subscribe to our blog updates