Make Your Microservice Architecture More Efficient by using RestQL V3

Make Your Microservice Architecture More Efficient by using RestQL V3

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.

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.

Query

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

Result:
{
"hero": {
"result": {
"name": "Restman", 
"mysidekick": 
{ 
"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.

Query

to users

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

Response:

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>
Restql
  .executeQuery(
    {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.

This is image title

This is image title

This is image title

Conclusion

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.

Hope this tutorial will surely help and you!

This post was originally published on dzone.com

Related Articles

A Beginner's Guide to Microservice Architecture with Example

Build Secure Microservices with AWS Lambda and ASP.NET Core

microservices sql graphql javascript web-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Hire Web Developer

Looking for an attractive & user-friendly web developer? HourlyDeveloper.io, a leading web, and mobile app development company, offers web developers for hire through flexible engagement models. You can **[Hire Web...

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

Important Reasons to Hire a Professional Web Development Company

    You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...