How RestQL V3 Can Make Your Microservice Architecture More Efficient

DZone 's Guide to

How RestQL V3 Can Make Your Microservice Architecture More Efficient

Because efficiency is everything.

· Microservices Zone ·
Free Resource

Efficiency is everything!

Efficiency is everything!

Recently released RestQL V3 has some advanced features that can make your microservice architecture more efficient and we are going to explore more about it through the eyes of a developer.

You may also like: YouTube Tutorials That Actually Teach You Some SQL

What Is a Microservice Architecture?

Microservice architecture is an aggregated form of several independent and automated services, working remotely with no or little centralized management. Each service has its own process running by remote machinery, to form a single application with a suite of multiple microservices. services are often an HTTP resource APIs. All the services are built on different business capabilities to achieve a business-specific suite of such services.

What Is RestQL?

RestQL is a microservice query language that aggregates information from several services and integrates them into your microservice architecture. There is no need for a server-side and all you need is to define the endpoints and run the RestQL server to start querying. RestQL is an open-source project available under MIT license.

RestQL is like any other REST service, so it does not need special access. RestQL is useful to simplify front-end code that needs to query multiple microservices. While a microservices architecture makes backend systems to support the front-end application layer with complex coding. RestQL reduces the complexity of calls to multiple microservices and improves the native browser caching functionality by the use of standard HTTP calls.

from product
With,productId = "156AB"

What Are the New Features in RestQL?

According to this source, RestQL V3 was released with some important new features which are given below:

  • Content aggregation.

  • Support for additional HTTP methods.

  • A self-healing system.

  • A JavaScript/ClojureScript version.

Content Aggregation

RestQL provides automatic parallel calls to separate resources. The individual responses would also be separated, which requires consolidation of related objects, In the latest version, the new 'in' operator allows the developer to specify the aggregation structure upfront in the query, resulting in a single, combined result.


from hero
name = "Restman"
from sidekick in hero.mysidekick
hero = hero.id

"hero": {
"result": {
"name": "Restman", 
"name": "Super get"

Support for Additional HTTP Methods

The latest version adds the standard set of HTTP verbs for CRUD operations, like POST, PUT, and DELETE, through the keywords to, into, and delete, respectively. While in earlier versions querying data was supported by using the FROM keyword, translated to an HTTP GET request.


to users

  with id = “user.id” 
  username = “user.name” 
  password = “super.secret”


POST http://some.api/users/ 
BODY { “id”: “user.id”, “username”: “user.name”, “password”: “super.secret” }

A Self-Healing System

Earlier RestQL used to offer low resilience to the request and queries overloaded due to low underlying hardware size. The latest version of RestQL has a self-healing system. In this system, whenever the system is overloaded by requests, it forms backpressure to configure a setting that gives HTTP 507 response to some requests, while allowing the partial requests to continue. To cure this pending failed requests, RestQL should be used with a mesh service to induce a retry logic.

The threshold can be configured by setting the max_query_overhead_ms environment variable which sets the maximum allowed processing time overhead for a given query. When this threshold is reached, the self-healing system is triggered. The default value is 50 ms. This allows CPU optimization while running a query through the RestQL server.

A JavaScript/ClojureScript Version

RestQL has released RestQL-js with this version, which helps developers to integrate the RestQL server directly into their Javascript without an extensive HTTP server, which currently works only on Node applications.
npm i @b2wdigital/restql

var restlq = require('@b2wdigital/restql')
// executeQuery(mappings, query, params, options) => <Promise>
    {user: "http://your.api.url/users/:name"},
    "from user with name = $name",
    { name: "Duke Nukem" })
  .then(response => console.log(response))
  .catch(error => console.log(error))

How Is the Performance of RestQL Compared to GraphQL?

Github conducted tests for comparison of the performance of restQL and GraphQL on benchmarks of query response and response time. Tests were done using the out of the box configuration of the tools involved. The environment used was one C5.large AWS instance which has the simplest configuration of the compute-optimized line (2 vCPU and 4GB RAM).

Tanker-go, which is an API, developed for the test, was used to create a consistent environment for all services called by RestQL. It allowed Github to measure response time by simulating effects on an actual request. Github also used Vegeta, which is an HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. Vegeta can be used both as a command-line utility and a library.

The results were evidence of the fact that RestQL is far better at resilience and response time than its ancestor, GraphQL.

5XX quantity vs. queries/sec

2XX quantity vs. queries/sec

Response time ms vs. queries/sec

response time ms vs. queries/sec


If you have a microservice structure to your application core, the use of RestQL can ensure far better response time to your queries and better resilience than its predecessors. So, RestQL V3 is highly recommendable for microservice architecture.

Further Reading

Java: How to Become More Productive With Hazelcast in Less Than 5 Minutes

Java Stream: Is a Count Always a Count?

microservices ,microservices architecture ,restql ,sql (structured query language)

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}