Skip to content

Commit 168a778

Browse files
committed
update prisma postgres hyperdrive doc, change in configuration of origin connectin limit
1 parent 880cb46 commit 168a778

File tree

1 file changed

+38
-4
lines changed
  • src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-database-providers

1 file changed

+38
-4
lines changed

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-database-providers/prisma-postgres.mdx

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar:
88
description: Connect Hyperdrive to a Prisma Postgres database.
99
---
1010

11-
import { Render } from "~/components";
11+
import { Render, TabItem, Tabs } from "~/components";
1212

1313
This example shows you how to connect Hyperdrive to a [Prisma Postgres](https://www.prisma.io/postgres) database.
1414

@@ -19,21 +19,55 @@ You can connect Hyperdrive to any existing Prisma Postgres database by using you
1919
### Prisma Data Platform
2020

2121
1. Go to the [**Prisma Data Platform Console**](https://console.prisma.io/) and select the project (database) you wish to connect to.
22-
2. Navigate to your database settings and copy the connection string for your Prisma Postgres database.
23-
3. Ensure the connection string includes the necessary credentials and database name.
22+
2. Navigate to your database settings, select **Connect to your database**, select **Any client**, and copy the connection string for your Prisma Postgres database.
23+
3. You must append **`postgres`** as the database in your connection string. Ensure the connection string includes the necessary credentials according to the format documented below:
24+
```txt
25+
postgres://USERNAME:PASSWORD@HOSTNAME_OR_IP_ADDRESS:PORT/database_name
26+
```
2427

2528
With the connection string, you can now create a Hyperdrive database configuration.
2629

2730
## 2. Create a database configuration
2831

2932
<Render file="create-hyperdrive-config" product="hyperdrive" />
3033

34+
## 4. Configure Hyperdrive maximum connections
35+
36+
Prisma Postgres has limits on the amount of connections that can be made direct to the database using Hyperdrive. Refer to [Prisma Postgres limits](https://www.prisma.io/docs/postgres/database/direct-connections?utm_source=website&utm_medium=postgres-page#connection-limit) to know the specific limits that apply to your database.
37+
3138
:::note
3239

33-
When configuring Hyperdrive for Prisma Postgres, set the maximum connections to 15 to stay within Prisma Postgres connection limits. You can configure this in the Cloudflare dashboard under Hyperdrive settings, or contact support if you need to adjust connection pooling settings.
40+
Hyperdrive's origin connection limit refers to the amount of database connections that Hyperdrive makes to your origin database (in this case, Prisma Postgres).
41+
This number should be less than your Prisma Postgres database since Hyperdrive's limit is a soft limit, and Hyperdrive may create more connections in the event of networking disruptions that prevent existing connections from being used.
3442

3543
:::
3644

45+
<Tabs>
46+
47+
<TabItem label={"Dashboard"}>
48+
1. From the [Cloudflare Hyperdrive dashboard](https://dash.cloudflare.com/?to=/:account/workers/hyperdrive), select your newly created Hyperdrive configuration.
49+
2. Navigate to **Settings**.
50+
3. In **Origin connection limit**, select **Edit Settings** and set your max connections to a number that is less than your Prisma connection limit.
51+
</TabItem>
52+
<TabItem label={"Wrangler CLI"}>
53+
54+
1. Edit your existing Hyperdrive configuration with the `--origin-connection-limit` parameter:
55+
56+
```bash
57+
npx wrangler hyperdrive update \<HYPERDRIVE_ID\> --origin-connection-limit=10
58+
```
59+
60+
Replace `<HYPERDRIVE_ID>` with your Hyperdrive configuration ID and set the connection limit to a number that is less than your Prisma connection limit.
61+
62+
2. Verify the configuration change:
63+
64+
```bash
65+
npx wrangler hyperdrive get \<HYPERDRIVE_ID\>
66+
```
67+
68+
</TabItem>
69+
</Tabs>
70+
3771
:::note
3872

3973
When connecting to a Prisma Postgres database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/) to connect directly to the underlying PostgreSQL database instead of the Prisma Accelerate extension. Hyperdrive is optimized for database access for Workers and will perform global connection pooling and fast query routing by connecting directly to your database.

0 commit comments

Comments
 (0)