-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into paritosh/eng-1391
- Loading branch information
Showing
14 changed files
with
331 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
title: Region Routing | ||
sidebar_position: 10 | ||
description: | ||
"Understand how to set up region routing in Hasura DDN to achieve efficient data fetching and lower latency. Benefit | ||
from optimal database performance and global data access with Hasura." | ||
keywords: | ||
- multi-region routing | ||
- region routing | ||
- hasura | ||
- postgreSQL | ||
- data fetching | ||
- latency | ||
- geo-routing | ||
- hasura data connector | ||
- database optimization | ||
seoFrontMatterUpdated: true | ||
--- | ||
|
||
# Region Routing | ||
|
||
## Introduction | ||
|
||
With region routing, you can define the deployment configuration of your data connector for different regions. | ||
|
||
For data connectors that connect to a data source, e.g. [PostgreSQL](/how-to-build-with-ddn/with-postgresql.mdx), it is | ||
recommended to deploy the connector in a region closest to the data source to ensure efficient communication between the | ||
connector and the data source. | ||
|
||
For other data connectors, e.g. [Typescript](https://hasura.io/connectors/nodejs), it is recommended to deploy the | ||
connector in a region closest to the consumers of the API to ensure efficient communication between the connector and | ||
the Hasura engine. | ||
|
||
If you have a distributed data source, with multi-region routing, you can ensure that data is fetched from the data | ||
source closest to the user, thus minimizing latency for the request, improving the performance of your application, and | ||
providing a better user experience. | ||
|
||
See the list of supported regions [below](#regions). | ||
|
||
## Single-Region Routing | ||
|
||
You can modify the `Connector` object as per the highlighted values in the example below to force the deployment of your | ||
data connector to a specific region. If the region is not specified, the connector will be deployed randomly to one of | ||
the [supported regions](#regions). | ||
|
||
```yaml title="For example, in my_subgraph/connector/my_connector/connector.yaml:" | ||
kind: Connector | ||
version: v2 | ||
definition: | ||
name: my_connector | ||
subgraph: my_subgraph | ||
source: hasura/connector_name:<version> | ||
context: . | ||
#highlight-start | ||
regionConfiguration: | ||
- region: <region from the list below> | ||
mode: ReadWrite | ||
envMapping: | ||
<CONNECTOR_ENV_VAR>: # e.g. CONNECTION_URI | ||
fromEnv: <CONNECTOR_ENV_VAR> # e.g. Env Var set as DB read write URL | ||
#highlight-end | ||
``` | ||
|
||
## Multi-Region Routing | ||
|
||
You can modify the `Connector` object as per the highlighted values in the example below to define the deployment | ||
configuration of your connector across multiple regions. | ||
|
||
:::note Currently only supported for PostgreSQL | ||
|
||
Multi-region routing is currently supported only for the | ||
[PostgreSQL connector](/how-to-build-with-ddn/with-postgresql.mdx). | ||
|
||
Support for other data connectors will be added soon. | ||
|
||
::: | ||
|
||
```yaml title="For example, in my_subgraph/connector/my_connector/connector.yaml:" | ||
kind: Connector | ||
version: v2 | ||
definition: | ||
name: my_connector | ||
subgraph: my_subgraph | ||
source: hasura/connector_name:<version> | ||
context: . | ||
#highlight-start | ||
regionConfiguration: | ||
- region: <region1: region from the list below> | ||
mode: ReadWrite | ||
envMapping: | ||
<CONNECTOR_ENV_VAR>: # e.g. CONNECTION_URI | ||
fromEnv: <CONNECTOR_ENV_VAR_REGION_1> # e.g. Env Var set as DB read write replica URL in region1 | ||
- region: <region2: region from the list below> | ||
mode: ReadOnly | ||
envMapping: | ||
<CONNECTOR_ENV_VAR>: # e.g. CONNECTION_URI | ||
fromEnv: <CONNECTOR_ENV_VAR_REGION_2> # e.g. Env Var set as DB read only replica URL in region2 | ||
- region: <region3: region from the list below> | ||
mode: ReadOnly | ||
envMapping: | ||
<CONNECTOR_ENV_VAR>: # e.g. CONNECTION_URI | ||
fromEnv: <CONNECTOR_ENV_VAR_REGION_3> # e.g. Env Var set as DB read only replica URL in region3 | ||
#highlight-end | ||
``` | ||
|
||
## Supported regions {#regions} | ||
|
||
Currently, Hasura DDN supports the following regions in GCP for multi-region routing: | ||
|
||
- `gcp-asia-south1` | ||
- `gcp-asia-southeast1` | ||
- `gcp-australia-southeast1` | ||
- `gcp-europe-west1` | ||
- `gcp-southamerica-east1` | ||
- `gcp-us-east4` | ||
- `gcp-us-west2` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
sidebar_position: 12 | ||
sidebar_label: Response Size Limit | ||
description: "Hasura rejects responses from a connector when their size exceeds a certain limit" | ||
keywords: | ||
- size limit | ||
- response size limit | ||
- connector response | ||
seoFrontMatterUpdated: true | ||
--- | ||
|
||
# Connector Response Size Limit | ||
|
||
The maximum size for responses from connectors is **30 MB**. Beyond this threshold, Hasura will reject the response to | ||
ensure optimum performance and data processing. It's important to be mindful of this constraint when making data queries | ||
to Hasura's [GraphQL API](/graphql-api/overview/). | ||
|
||
To prevent hitting the response size limit, API consumers are encouraged to utilize the | ||
[limit argument](/graphql-api/queries/pagination#limit-results) in their queries to avoid over-fetching data from | ||
sources via data connectors. | ||
|
||
When GraphQL API requests exceed this size limit, they will result in an | ||
[internal error](/graphql-api/errors#internal-errors) API response. | ||
|
||
```json | ||
{ | ||
"data": null, | ||
"errors": [ | ||
{ | ||
"message": "internal error" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
Hasura users are advised to check the traces for more detailed error information, which includes the actual response | ||
size from the connector. | ||
|
||
:::note Response size limit increases | ||
|
||
If you require an increase in the response size limit, please reach out to [Hasura support](https://hasura.io/help/) for | ||
assistance. | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import siteConfig from '@generated/docusaurus.config'; | ||
import Tracker from '@openreplay/tracker'; | ||
|
||
const OPENREPLAY_SESSION_COOKIE = 'openReplaySessionHash'; | ||
const OPENREPLAY_INGEST_POINT = siteConfig.customFields.openReplayIngestPoint as string; | ||
const OPENREPLAY_PROJECT_KEY = siteConfig.customFields.openReplayProjectKey as string; | ||
|
||
let tracker: Tracker | null = null; | ||
|
||
export const initOpenReplay = async () => { | ||
const { default: Tracker } = await import('@openreplay/tracker'); | ||
tracker = new Tracker({ | ||
projectKey: OPENREPLAY_PROJECT_KEY, | ||
ingestPoint: OPENREPLAY_INGEST_POINT, | ||
__DISABLE_SECURE_MODE: true, | ||
}); | ||
}; | ||
|
||
export const startOpenReplayTracking = (userId?: string) => { | ||
if (tracker) { | ||
const cookies = document.cookie.split('; '); | ||
const cookie = cookies.find(c => c.startsWith(`${OPENREPLAY_SESSION_COOKIE}=`)); | ||
const existingSessionHash = cookie ? cookie.split('=')[1] : null; | ||
|
||
if (existingSessionHash) { | ||
// Resume existing session | ||
tracker.start({ sessionHash: existingSessionHash }); | ||
} else { | ||
// Start a new session | ||
tracker.start(); | ||
const newSessionHash = tracker.getSessionToken(); | ||
if (newSessionHash) { | ||
document.cookie = `${OPENREPLAY_SESSION_COOKIE}=${newSessionHash};`; | ||
} | ||
} | ||
|
||
// Set the user ID in both cases | ||
tracker.setUserID(userId); | ||
} else { | ||
console.warn('OpenReplay tracker is not initialized'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.