Categories

(111)
(64)
(170)
(22)

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

1 vote, Rating: 5

Read also

1

Even when salt, shells or stones were used instead of money, the most successful sellers were those relying on marketing and analytics! Today, with modern online stores and...

2

As we are a web development company, we work with web projects every day and can tell a lot about them. We want to bust the...

3

This article will help you evaluate the pros and cons and decide whether a fixed price contract is your fit or not and how you’ll benefit when choosing it.

4

We described what benefits HTTPS will bring to your website.

5

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

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