Skip to content

Commit b58264a

Browse files
jberrymanhasura-bot
authored andcommitted
Make redis connection pool max sizes configurable, bump default
PR-URL: hasura/graphql-engine-mono#11382 GitOrigin-RevId: becf8cf3a07ed1fcc824b479c056d04265058817
1 parent 6035ab2 commit b58264a

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

docs/docs/caching/enterprise-caching.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ HASURA_GRAPHQL_RATE_LIMIT_REDIS_TLS_HOSTNAME="redishostname"
6666
You can tune the various caching parameters according to your use-case. For example, you can configure the maximum
6767
TTL allowed, the max entry size in the cache etc.
6868

69-
| Env var | Flag | Description |
70-
|---------------------------------------|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
71-
| `HASURA_GRAPHQL_CACHE_MAX_ENTRY_TTL` | `--query-cache-max-ttl` | Maximum TTL allowed in seconds. Clients can request TTL via the `@cached` directive. But an upper limit can be set using this setting. Default: 3600 seconds |
72-
| `HASURA_GRAPHQL_CACHE_MAX_ENTRY_SIZE` | `--query-cache-max-entry-size` | Maximum size of the response that is allowed to be cached (in MB). default: 1000 MB |
73-
| `HASURA_GRAPHQL_CACHE_BUCKET_RATE` | `--query-cache-bucket-rate` | Recharge rate for the Query Response Cache token bucket. Default: 10,000,000 bytes/second (10 MB/s) |
74-
| `HASURA_GRAPHQL_CACHE_BUCKET_SIZE` | `--query-cache-bucket-size` | Maximum capacity in bytes for the Query Response Cache token bucket algorithm. See https://hasura.io/docs/latest/queries/response-caching for more info. Default: 1000000000 bytes (1 GB) |
69+
| Env var | Flag | Description |
70+
|------------------------------------------------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
71+
| `HASURA_GRAPHQL_CACHE_MAX_ENTRY_TTL` | `--query-cache-max-ttl` | Maximum TTL allowed in seconds. Clients can request TTL via the `@cached` directive. But an upper limit can be set using this setting. Default: 3600 seconds |
72+
| `HASURA_GRAPHQL_CACHE_MAX_ENTRY_SIZE` | `--query-cache-max-entry-size` | Maximum size of the response that is allowed to be cached (in MB). default: 1000 MB |
73+
| `HASURA_GRAPHQL_CACHE_BUCKET_RATE` | `--query-cache-bucket-rate` | Recharge rate for the Query Response Cache token bucket. Default: 10,000,000 bytes/second (10 MB/s) |
74+
| `HASURA_GRAPHQL_CACHE_BUCKET_SIZE` | `--query-cache-bucket-size` | Maximum capacity in bytes for the Query Response Cache token bucket algorithm. See https://hasura.io/docs/latest/queries/response-caching for more info. Default: 1000000000 bytes (1 GB) |
75+
| `HASURA_GRAPHQL_CACHING_REDIS_POOL_SIZE` | `--caching-redis-pool-size` | Maximum number of connections in the caching Redis connection pool. Default: 500 |
76+
| `HASURA_GRAPHQL_RATE_LIMIT_REDIS_POOL_SIZE` | `--rate-limit-redis-pool-size` | Maximum number of connections in the rate-limiting Redis connection pool. Default: 500 |
7577

7678

7779
### How to tune these parameters

docs/docs/deployment/graphql-engine-flags/reference.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,30 @@ The path to a shared CA store to use to connect to both (caching and rate-limiti
11011101
| **Default** | `null` |
11021102
| **Supported in** | Enterprise Edition only |
11031103

1104+
### Caching Redis Pool Size
1105+
1106+
Maximum number of connections in the caching Redis connection pool. For high-traffic production environments, you may want to increase this value. For development or low-traffic environments, you can decrease it to conserve resources.
1107+
1108+
| | |
1109+
| ------------------- | ------------------------------------------- |
1110+
| **Flag** | `--caching-redis-pool-size` |
1111+
| **Env var** | `HASURA_GRAPHQL_CACHING_REDIS_POOL_SIZE` |
1112+
| **Accepted values** | Integer |
1113+
| **Default** | `500` |
1114+
| **Supported in** | Enterprise Edition only |
1115+
1116+
### Rate Limit Redis Pool Size
1117+
1118+
Maximum number of connections in the rate-limiting Redis connection pool. For high-traffic production environments with heavy rate-limiting usage, you may want to increase this value. For development or low-traffic environments, you can decrease it to conserve resources.
1119+
1120+
| | |
1121+
| ------------------- | ------------------------------------------- |
1122+
| **Flag** | `--rate-limit-redis-pool-size` |
1123+
| **Env var** | `HASURA_GRAPHQL_RATE_LIMIT_REDIS_POOL_SIZE` |
1124+
| **Accepted values** | Integer |
1125+
| **Default** | `500` |
1126+
| **Supported in** | Enterprise Edition only |
1127+
11041128
### Redis URL
11051129

11061130
The Redis URL to use for [query caching](/caching/enterprise-caching.mdx) and

server/forks/hedis/src/Database/Redis/Connection.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ instance Exception ConnectError
107107
-- connectPort = PortNumber 6379 -- Redis default port
108108
-- connectAuth = Nothing -- No password
109109
-- connectDatabase = 0 -- SELECT database 0
110-
-- connectMaxConnections = 50 -- Up to 50 connections
110+
-- connectMaxConnections = 500 -- Up to 500 connections
111111
-- connectMaxIdleTime = 30 -- Keep open for 30 seconds
112112
-- connectTimeout = Nothing -- Don't add timeout logic
113113
-- connectTLSParams = Nothing -- Do not use TLS
@@ -120,7 +120,10 @@ defaultConnectInfo = ConnInfo
120120
, connectAuth = Nothing
121121
, connectReadOnly = False
122122
, connectDatabase = 0
123-
, connectMaxConnections = 50
123+
-- This keeps us several orders of magnitude below default limit, and
124+
-- typical limits of managed services AFAICT. Also see:
125+
-- https://redis.io/docs/latest/operate/oss_and_stack/management/optimization/benchmarks/?utm_source=chatgpt.com#factors-impacting-redis-performance
126+
, connectMaxConnections = 500
124127
, connectMaxIdleTime = 30
125128
, connectTimeout = Nothing
126129
, connectTLSParams = Nothing

0 commit comments

Comments
 (0)