Scalable GraphQL Applications Powered by Cloud-ready Distributed SQL Database

Rate this content
Bookmark

Cloud native application development revolves around faster prototyping and building scalable applications for handling internet-scale traffic. GraphQL, with its roots in providing a flexible way to access data for UX applications, enables faster prototyping, leading to considerable adoption of GraphQL across different workloads. Increased adoption of GraphQL APIs in mission-critical applications prompts developers to think about the scalability challenges of the GraphQL APIs and corresponding backing database.


YugateDB, an open-source Distributed SQL database designed for cloud native applications from the ground up, is emerging as the popular option for building scalable and resilient GraphQL APIs. This talk will go over the features and deployment topologies of YugateDB, which allows developers to scale the relational queries of the GraphQL APIs seamlessly while not compromising on the PostgreSQL compatibility and features like triggers and functions.

8 min
10 Dec, 2021

Video Summary and Transcription

YugabyteDB is an open-source distributed SQL database that offers horizontal scalability and geo-distribution while maintaining Postgres compatibility. It enables building scalable and always-on GraphQL services by allowing the workload to be scaled through the addition of new nodes and deployment across different regions or clouds. YugabyteDB also supports geo-partitioning and data compliance. It can easily handle increasing GraphQL workloads and can be tried out by downloading the database or using the Yugabyte Cloud platform.

1. Introduction to YugobyteDB and Distributed SQL

Short description:

I will talk about building scalable and always-on GraphQL services using distributed SQL database. YugobyteDB is a 100% open-source distributed SQL database that provides horizontal scalability for relational workloads and geo-distribution of the dataset while maintaining Postgres compatibility.

Thanks you all for joining. My name is Nikhil Chandrapa. I work in the ecosystem engineering team of YugibyteDB. We are a database startup. I work in the – we kind of work in implementing ecosystem integrations for the popular developer tools like GraphQL, Spring Framework, and host of other cloud native projects.

In today's session, I wanted to talk about how we can build scalable and always on GraphQL services using distributed SQL database. In this talk, we are going to talk through what distributed SQL means and how some of the topologies of distributed SQL can help natively scale the GraphQL workload.

Before I get into scaling the GraphQL workflow itself, I just wanted to give a brief of YugobyteDB. YugobyteDB is a 100% open-source distributed SQL database. It's where we are going to provide horizontal scalability for the relational workloads and also able to provide geo-distribution of the dataset. While maintaining the Postgres compatibility, which means all the things that you will be doing with Postgres like SQL joins, some of the things like triggers functions, will continue to work with Yugobyte. But the data distribution will be in a different format.

2. Building Scalable and Always-On GraphQL Services

Short description:

YugabyteDB founders aimed to build a database that combines high availability with distributed capabilities. Distributed SQL allows scaling the workload by adding new nodes and deploying across different regions or clouds. It also enables geo-partitioning and data compliance. YugabyteDB can easily scale to handle increasing GraphQL workloads by adding new nodes. You can try it out by downloading the database or using the Yugabyte Cloud platform. If you have any questions or are interested in joining our team, reach out to us on Slack or visit our careers page.

YugobyteDB founders, when they started building the database itself, they wanted to build a database which can provide high availability like Amazon Aurora while supporting all the RDBMS features and also provide a distributed capability like Spanner where you can horizontally scale the relational workload as well as support your distribution. So, obviously, when coming to the actual topic, when it comes to the GraphQL itself, GraphQL is pretty simple how you get started. You have a GraphQL server, you connect it to your database, and you can start working with building your APIs.

As and when you finish building your API, you get to this problem where how do you scale your services, right? One of the harder problems is to scale your database workload itself. So, the database can reach its resource limitations, you might have to do query limiting, the latencies might increase. In order to that distributed SQL will help where you can keep adding new nodes to the cluster and it can easily scale out the workload without having much management things that as a developer you'll have to do. You just run a cli command on the graphical UI, you just say, scale from 500 transactions to 1000 transactions, it will automatically figure out what needs to be done behind the scenes and scale out the cluster.

And also apart from scaling out the database there's like few things that you have to take care when you want to run always on kind of a service, right? Obviously, where you deploy your database, whether you deploy it in your one region or a different cloud that matters. With distributed SQL like you got by DB, you are able to make use of the geo distribution topologies we support and you can either deploy across different availability zones, regions or cloud. Recently, we had that Amazon cloud outage right where both east and west regions went down for that many of the internet scale applications like popular apps went down. In order to avoid such a thing you would want to deploy your applications on two different clouds so that one of the main things you would want to do in such cases is to have your data tier available across the globe or across the geographical locations. That's how distributed SQL topologies will help to continue your business so that you don't have a lot of financial loss. And also you're able to do things like geo-partitioning and data compliance. In Nougatbyte, there is a concept of row-level data placement where based on a certain column, like a geographical location, E.U. or U.S., you can have certain rows only reside in the server of that particular region. Such that you would not have to manually take care of the compliance. The database will do it for you. That's how we have been able to develop this database from ground up for the cloud-native architecture, keeping the modern database technologies and data tier requirements in mind.

One of the things for us to make sure that Nougatbyte can work for the GraphQL kind of workloads, what we did is we took GraphQL subscription and we wanted to scale it out linearly, so that we know whenever we are going to the customer or the actual production workload itself, what we are able to do and obviously numbers talk all the time. We started with a simple three-node cluster where we were handling around 25,000 subscriptions and we were able to linearly scale out that workload, the GraphQL workload, it was a simple GraphQL workload which we had serving through Hasura, but the database itself was able to scale to handle 25,000 transactions to a million subscriptions such that we didn't have to do a lot of things. The same architecture was able to scale to 1 million subscribers just by adding new nodes to the database. So you can start small, as and when your GraphQL workload or the services or the API that you are serving through GraphQL kind of increases or increases in use, you can keep adding new nodes. So it will be much simpler than adding read replicas or other things because the distributed SQL database knows how to place the data and how to route the query traffic and kind of all the other things that are required for handling a distributed kind of a process is already built into the database. That's how we are able to easily scale out the database.

If you are interested in this particular piece of exercise, you can go ahead and see our GitHub. You can go to Navigate to Yugabyte and Yugabyte GraphQL Apps. You will see that. Obviously, you might be thinking how do I try it out, right? It's an open source database. You can just download the database on your Mac laptop and you can just quickly start it up. And also we are providing – recently we announced our Yugabyte Cloud platform where you can go ahead and start a free trial instance of Yugabyte DB and play around with your GraphQL workloads. It is super simple. It kind of takes care of all the install and manage part of running the database and also it supports linear scalability. It will be super easy for you to get started and if you have any questions regarding how you can get started with cloud or Yugabyte DB, please reach out to us. You can reach out to us on our Slack. We will be always active on Slack and also we are actively hiring a lot. We are now a unicorn company. If you are interested in solving distributed SQL or some of the GraphQL related workloads with Yugabyte DB, please feel free to see our careers page.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
We all love GraphQL, but it can be daunting to get a server up and running and keep your code organized, maintainable, and testable over the long term. No more! Come watch as I go from an empty directory to a fully fledged GraphQL API in minutes flat. Plus, see how easy it is to use and create directives to clean up your code even more. You're gonna love GraphQL even more once you make things Redwood Easy!
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
How many times did you implement the same flow in your application: check, if data is already fetched from the server, if yes - render the data, if not - fetch this data and then render it? I think I've done it more than ten times myself and I've seen the question about this flow more than fifty times. Unfortunately, our go-to state management library, Vuex, doesn't provide any solution for this.For GraphQL-based application, there was an alternative to use Apollo client that provided tools for working with the cache. But what if you use REST? Luckily, now we have a Vue alternative to a react-query library that provides a nice solution for working with server cache. In this talk, I will explain the distinction between local application state and local server cache and do some live coding to show how to work with the latter.
GraphQL Galaxy 2022GraphQL Galaxy 2022
16 min
Step aside resolvers: a new approach to GraphQL execution
Though GraphQL is declarative, resolvers operate field-by-field, layer-by-layer, often resulting in unnecessary work for your business logic even when using techniques such as DataLoader. In this talk, Benjie will introduce his vision for a new general-purpose GraphQL execution strategy whose holistic approach could lead to significant efficiency and scalability gains for all GraphQL APIs.

Workshops on related topic

GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Top Content
Featured WorkshopFree
Have you ever thought about building something that doesn't require a lot of boilerplate with a tiny bundle size? In this workshop, Scott Spence will go from hello world to covering routing and using endpoints in SvelteKit. You'll set up a backend GraphQL API then use GraphQL queries with SvelteKit to display the GraphQL API data. You'll build a fast secure project that uses SvelteKit's features, then deploy it as a fully static site. This course is for the Svelte curious who haven't had extensive experience with SvelteKit and want a deeper understanding of how to use it in practical applications.

Table of contents:
- Kick-off and Svelte introduction
- Initialise frontend project
- Tour of the SvelteKit skeleton project
- Configure backend project
- Query Data with GraphQL
- Fetching data to the frontend with GraphQL
- Styling
- Svelte directives
- Routing in SvelteKit
- Endpoints in SvelteKit
- Deploying to Netlify
- Navigation
- Mutations in GraphCMS
- Sending GraphQL Mutations via SvelteKit
- Q&A
React Advanced Conference 2022React Advanced Conference 2022
95 min
End-To-End Type Safety with React, GraphQL & Prisma
Featured WorkshopFree
In this workshop, you will get a first-hand look at what end-to-end type safety is and why it is important. To accomplish this, you’ll be building a GraphQL API using modern, relevant tools which will be consumed by a React client.
Prerequisites: - Node.js installed on your machine (12.2.X / 14.X)- It is recommended (but not required) to use VS Code for the practical tasks- An IDE installed (VSCode recommended)- (Good to have)*A basic understanding of Node.js, React, and TypeScript
GraphQL Galaxy 2022GraphQL Galaxy 2022
112 min
GraphQL for React Developers
Featured Workshop
There are many advantages to using GraphQL as a datasource for frontend development, compared to REST APIs. We developers in example need to write a lot of imperative code to retrieve data to display in our applications and handle state. With GraphQL you cannot only decrease the amount of code needed around data fetching and state-management you'll also get increased flexibility, better performance and most of all an improved developer experience. In this workshop you'll learn how GraphQL can improve your work as a frontend developer and how to handle GraphQL in your frontend React application.
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
Top Content
WorkshopFree
In this workshop, you’ll learn how to build a Next.js app that uses Apollo Client to fetch data from a headless WordPress backend and use it to render the pages of your app. You’ll learn when you should consider a headless WordPress architecture, how to turn a WordPress backend into a GraphQL server, how to compose queries using the GraphiQL IDE, how to colocate GraphQL fragments with your components, and more.
GraphQL Galaxy 2020GraphQL Galaxy 2020
106 min
Relational Database Modeling for GraphQL
Top Content
WorkshopFree
In this workshop we'll dig deeper into data modeling. We'll start with a discussion about various database types and how they map to GraphQL. Once that groundwork is laid out, the focus will shift to specific types of databases and how to build data models that work best for GraphQL within various scenarios.
Table of contentsPart 1 - Hour 1      a. Relational Database Data Modeling      b. Comparing Relational and NoSQL Databases      c. GraphQL with the Database in mindPart 2 - Hour 2      a. Designing Relational Data Models      b. Relationship, Building MultijoinsTables      c. GraphQL & Relational Data Modeling Query Complexities
Prerequisites      a. Data modeling tool. The trainer will be using dbdiagram      b. Postgres, albeit no need to install this locally, as I'll be using a Postgres Dicker image, from Docker Hub for all examples      c. Hasura
GraphQL Galaxy 2021GraphQL Galaxy 2021
48 min
Building GraphQL APIs on top of Ethereum with The Graph
WorkshopFree
The Graph is an indexing protocol for querying networks like Ethereum, IPFS, and other blockchains. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.

In this workshop you’ll learn how to build a subgraph that indexes NFT blockchain data from the Foundation smart contract. We’ll deploy the API, and learn how to perform queries to retrieve data using various types of data access patterns, implementing filters and sorting.

By the end of the workshop, you should understand how to build and deploy performant APIs to The Graph to index data from any smart contract deployed to Ethereum.