Skip to content

Commit

Permalink
Merge branch 'main' into bgrenon-org-api-project-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrenon committed Dec 13, 2024
2 parents d8d10ec + 5cb64ee commit d6968bf
Show file tree
Hide file tree
Showing 60 changed files with 1,739 additions and 258 deletions.
5 changes: 3 additions & 2 deletions content/docs/ai/ai-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ title: AI & Embeddings
subtitle: Power AI agents with serverless Postgres — and build AI applications with Neon
as your vector database
enableTableOfContents: true
updatedOn: '2024-12-11T13:29:14.045Z'
updatedOn: '2024-12-12T19:49:26.793Z'
---

Neon enables AI agents to provision Postgres databases in seconds, execute SQL queries, and easily manage Neon infrastructure. With one-second provision times, scale-to-zero compute, and agent-friendly Neon API interfaces, Neon lets AI agents manage database fleets at scale while minimizing costs. [Learn more about this use case](https://neon.tech/use-cases/ai-agents).

Neon also supports vector data, a key component for AI applications. With the **pgvector** open-source extension, you can use Neon as a vector database for storing and querying embeddings. This allows you to Postgres as your vector store, eliminating the need for data migration or third-party solutions.
Neon also supports vector data, a key component for AI applications. With the **pgvector** open-source extension, you can use Neon as a vector database for storing and querying embeddings. This allows you to use Postgres as your vector store, eliminating the need for data migration or third-party solutions.

## Neon for AI Agents

Expand Down Expand Up @@ -48,6 +48,7 @@ The **Neon AI Starter Kit** includes:
### AI basics

<DetailIconCards>

<a href="/docs/ai/ai-concepts" description="Learn how embeddings are used to build AI applications" icon="openai">AI concepts</a>

<a href="/docs/extensions/pgvector" description="Learn about the pgvector Postgres extension" icon="openai">The pgvector extension</a>
Expand Down
60 changes: 43 additions & 17 deletions content/docs/ai/ai-scale-with-neon.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,53 @@
title: Scale your AI application with Neon
subtitle: Scale your AI application with Neon's Autoscaling and Read Replica features
enableTableOfContents: true
updatedOn: '2024-12-01T21:48:07.687Z'
updatedOn: '2024-12-11T21:23:33.080Z'
---

You can scale your AI application built on Postgres with `pgvector` in the same way you would any Postgres app: Vertically with added CPU, RAM, and storage, or horizontally with read replicas.

In Neon, scaling vertically is a matter of selecting the desired compute size. Neon supports compute sizes ranging from .025 vCPU with 1 GB RAM up to 10 vCPU with 40 GB RAM.

| Compute Units (CU) | vCPU | RAM | maintenance_work_mem |
| :----------------- | :--- | :---- | :------------------- |
| 0.25 | 0.25 | 1 GB | 64 MB |
| 0.50 | 0.50 | 2 GB | 64 MB |
| 1 | 1 | 4 GB | 67 MB |
| 2 | 2 | 8 GB | 134 MB |
| 3 | 3 | 12 GB | 201 MB |
| 4 | 4 | 16 GB | 268 MB |
| 5 | 5 | 20 GB | 335 MB |
| 6 | 6 | 24 GB | 402 MB |
| 7 | 7 | 28 GB | 470 MB |
| 8 | 8 | 32 GB | 537 MB |
| 9 | 9 | 36 GB | 604 MB |
| 10 | 10 | 40 GB | 671 MB |
In Neon, scaling vertically is a matter of selecting the desired compute size. Neon supports compute sizes ranging from .025 vCPU with 1 GB RAM up to 56 vCPU with 224 GB RAM. Autoscaling is supported up to 16 vCPU. Larger computes are fixed size computes (no autoscaling). The `maintenance_work_mem` values shown below are approximate.

| Compute Units (CU) | vCPU | RAM | maintenance_work_mem |
| :----------------- | :--- | :----- | :------------------- |
| 0.25 | 0.25 | 1 GB | 64 MB |
| 0.50 | 0.50 | 2 GB | 64 MB |
| 1 | 1 | 4 GB | 67 MB |
| 2 | 2 | 8 GB | 134 MB |
| 3 | 3 | 12 GB | 201 MB |
| 4 | 4 | 16 GB | 268 MB |
| 5 | 5 | 20 GB | 335 MB |
| 6 | 6 | 24 GB | 402 MB |
| 7 | 7 | 28 GB | 470 MB |
| 8 | 8 | 32 GB | 537 MB |
| 9 | 9 | 36 GB | 604 MB |
| 10 | 10 | 40 GB | 671 MB |
| 11 | 11 | 44 GB | 738 MB |
| 12 | 12 | 48 GB | 805 MB |
| 13 | 13 | 52 GB | 872 MB |
| 14 | 14 | 56 GB | 939 MB |
| 15 | 15 | 60 GB | 1007 MB |
| 16 | 16 | 64 GB | 1074 MB |
| 18 | 18 | 72 GB | 1208 MB |
| 20 | 20 | 80 GB | 1342 MB |
| 22 | 22 | 88 GB | 1476 MB |
| 24 | 24 | 96 GB | 1610 MB |
| 26 | 26 | 104 GB | 1744 MB |
| 28 | 28 | 112 GB | 1878 MB |
| 30 | 30 | 120 GB | 2012 MB |
| 32 | 32 | 128 GB | 2146 MB |
| 34 | 34 | 136 GB | 2280 MB |
| 36 | 36 | 144 GB | 2414 MB |
| 38 | 38 | 152 GB | 2548 MB |
| 40 | 40 | 160 GB | 2682 MB |
| 42 | 42 | 168 GB | 2816 MB |
| 44 | 44 | 176 GB | 2950 MB |
| 46 | 46 | 184 GB | 3084 MB |
| 48 | 48 | 192 GB | 3218 MB |
| 50 | 50 | 200 GB | 3352 MB |
| 52 | 52 | 208 GB | 3486 MB |
| 54 | 54 | 216 GB | 3620 MB |
| 56 | 56 | 224 GB | 3754 MB |

See [Edit a compute](/docs/manage/endpoints#edit-a-compute) to learn how to configure your compute size. Available compute sizes differ according to your Neon plan. The Neon Free Plan supports computes starting at 0.25 CU, up to 2 CU with autoscaling enabled. The Launch plan offers compute sizes up to 4 CU. Larger computes are available on the Scale and Business plans. See [Neon plans](/docs/introduction/plans).

Expand Down
14 changes: 14 additions & 0 deletions content/docs/connect/connection-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This topic describes how to resolve connection errors you may encounter when usi
- [You have exceeded the limit of concurrently active endpoints](#you-have-exceeded-the-limit-of-concurrently-active-endpoints)
- [Remaining connection slots are reserved for roles with the SUPERUSER attribute](#remaining-connection-slots-are-reserved-for-roles-with-the-superuser-attribute)
- [Relation not found](#relation-not-found)
- [query_wait_timeout SSL connection has been closed unexpectedly](#querywaittimeout-ssl-connection-has-been-closed-unexpectedly)
- [The request could not be authorized due to an internal error](#the-request-could-not-be-authorized-due-to-an-internal-error)

<Admonition type="info">
Connection problems are sometimes related to a system issue. To check for system issues, please refer to the [Neon status page](https://neonstatus.com/).
Expand Down Expand Up @@ -219,4 +221,16 @@ If you are already using connection pooling, you may need to reach out to Neon S

This error is often encountered when attempting to set the Postgres `search_path` session variable using a `SET search_path` statement over a pooled connection. For more information and workarounds, please see [Connection pooling in transaction mode](/docs/connect/connection-pooling#connection-pooling-in-transaction-mode).

## query_wait_timeout SSL connection has been closed unexpectedly

The `query_wait_timeout` setting is a PgBouncer configuration option that determines the maximum time a query can wait in the queue before being executed. Neon’s default value for this setting is **120 seconds**. If a query exceeds this timeout while in the queue, it will not be executed. For more details about this setting, refer to [Neon PgBouncer configuration settings](/docs/connect/connection-pooling#neon-pgbouncer-configuration-settings).

To avoid this error, we recommend reviewing your workload. If it includes batch processing with `UPDATE` or `INSERT` statements, review their performance. Slow queries may be the root cause. Try optimizing these queries to reduce execution time, which can help prevent them from exceeding the timeout.

Alternatively, Neon can increase the `query_wait_timeout` value for you, but this is not typically recommended, as increasing the timeout can lead to higher latency or blocked queries under heavy workloads.

## The request could not be authorized due to an internal error

This error page in the Neon Console is most often the result of attempting to access a Neon project in one browser window after you've have logged in under a different Neon user account from another browser window. The error occurs because the currently logged in Neon user account does not have access to the Neon project. To avoid this issue, ensure that you're logged in with a Neon user account that has access to the Neon project you're trying to access.

<NeedHelp/>
56 changes: 41 additions & 15 deletions content/docs/connect/connection-pooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ subtitle: Learn how connection pooling works in Neon
enableTableOfContents: true
redirectFrom:
- /docs/get-started-with-neon/connection-pooling
updatedOn: '2024-11-30T11:53:56.048Z'
updatedOn: '2024-12-11T21:23:33.083Z'
---

Neon uses [PgBouncer](https://www.pgbouncer.org/) to support connection pooling, enabling up to 10,000 concurrent connections. PgBouncer is a lightweight connection pooler for Postgres.
Expand All @@ -29,20 +29,46 @@ The `-pooler` option routes the connection to a connection pooling port at the N

Each Postgres connection creates a new process in the operating system, which consumes resources. Postgres limits the number of open connections for this reason. The Postgres connection limit is defined by the Postgres `max_connections` parameter. In Neon, `max_connections` is set according to your compute size &#8212; and if you are using Neon's Autoscaling feature, it is set according to your **minimum** compute size.

| Compute Size (CU) | vCPU | RAM | max_connections |
| :---------------- | :--- | :---- | :-------------- |
| 0.25 | 0.25 | 1 GB | 112 |
| 0.50 | 0.50 | 2 GB | 225 |
| 1 | 1 | 4 GB | 450 |
| 2 | 2 | 8 GB | 901 |
| 3 | 3 | 12 GB | 1351 |
| 4 | 4 | 16 GB | 1802 |
| 5 | 5 | 20 GB | 2253 |
| 6 | 6 | 24 GB | 2703 |
| 7 | 7 | 28 GB | 3154 |
| 8 | 8 | 32 GB | 3604 |
| 9 | 9 | 36 GB | 4000 |
| 10 | 10 | 40 GB | 4000 |
| Compute Size (CU) | vCPU | RAM | max_connections |
| :---------------- | :--- | :----- | :-------------- |
| 0.25 | 0.25 | 1 GB | 112 |
| 0.50 | 0.50 | 2 GB | 225 |
| 1 | 1 | 4 GB | 450 |
| 2 | 2 | 8 GB | 901 |
| 3 | 3 | 12 GB | 1351 |
| 4 | 4 | 16 GB | 1802 |
| 5 | 5 | 20 GB | 2253 |
| 6 | 6 | 24 GB | 2703 |
| 7 | 7 | 28 GB | 3154 |
| 8 | 8 | 32 GB | 3604 |
| 9 | 9 | 36 GB | 4000 |
| 10 | 10 | 40 GB | 4000 |
| 11 | 11 | 44 GB | 4000 |
| 12 | 12 | 48 GB | 4000 |
| 13 | 13 | 52 GB | 4000 |
| 14 | 14 | 56 GB | 4000 |
| 15 | 15 | 60 GB | 4000 |
| 16 | 16 | 64 GB | 4000 |
| 18 | 18 | 72 GB | 4000 |
| 20 | 20 | 80 GB | 4000 |
| 22 | 22 | 88 GB | 4000 |
| 24 | 24 | 96 GB | 4000 |
| 26 | 26 | 104 GB | 4000 |
| 28 | 28 | 112 GB | 4000 |
| 30 | 30 | 120 GB | 4000 |
| 32 | 32 | 128 GB | 4000 |
| 34 | 34 | 136 GB | 4000 |
| 36 | 36 | 144 GB | 4000 |
| 38 | 38 | 152 GB | 4000 |
| 40 | 40 | 160 GB | 4000 |
| 42 | 42 | 168 GB | 4000 |
| 44 | 44 | 176 GB | 4000 |
| 46 | 46 | 184 GB | 4000 |
| 48 | 48 | 192 GB | 4000 |
| 50 | 50 | 200 GB | 4000 |
| 52 | 52 | 208 GB | 4000 |
| 54 | 54 | 216 GB | 4000 |
| 56 | 56 | 224 GB | 4000 |

The formula used to calculate `max_connections` for Neon computes is `RAM in bytes / 9531392 bytes`. For a Neon Free Plan compute, which has 1 GB of RAM, this works out to approximately 112 connections. Larger computes offered with paid plans have more RAM and therefore support a larger number of connections. For example, a compute with 12 GB of RAM supports up to 1351 connections. You can check the `max_connections` limit for your compute by running the following query from the Neon SQL Editor or a client connected to Neon:

Expand Down
4 changes: 2 additions & 2 deletions content/docs/extensions/neon-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: The neon_utils extension
subtitle: Monitor how Neon's Autoscaling feature allocates compute resources
enableTableOfContents: true
updatedOn: '2024-11-30T11:53:56.049Z'
updatedOn: '2024-12-11T21:23:33.084Z'
---

The `neon_utils` extension provides a `num_cpus()` function you can use to monitor how Neon's _Autoscaling_ feature allocates vCPU in response to workload. The function returns the current number of allocated vCPUs.
Expand All @@ -21,7 +21,7 @@ For information about using the Neon **SQL Editor**, see [Query with Neon's SQL

## Use the `num_cpus()` function

In Neon, computing capacity is measured in _Compute Units (CU)_. One CU is 1 vCPU and 4 GB of RAM, 2 CU is 2 vCPU and 8 GB of RAM, and so on. The amount of RAM in GB is always 4 times the number of vCPU. A Neon compute can have anywhere from .25 to 10 CU.
In Neon, computing capacity is measured in _Compute Units (CU)_. One CU is 1 vCPU and 4 GB of RAM, 2 CU is 2 vCPU and 8 GB of RAM, and so on. The amount of RAM in GB is always 4 times the number of vCPU. A Neon compute can have anywhere from .25 to 56 CU, but _Autoscaling_ is only supported up to 16 CU.

Defining a minimum and maximum compute size for your compute, as shown below, enables autoscaling.

Expand Down
4 changes: 2 additions & 2 deletions content/docs/extensions/neon.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: The neon extension
subtitle: An extension for Neon-specific statistics including the Local File Cache hit
ratio
enableTableOfContents: true
updatedOn: '2024-10-13T09:21:28.913Z'
updatedOn: '2024-12-11T19:49:53.139Z'
---

The `neon` extension provides functions and views designed to gather Neon-specific metrics.
Expand Down Expand Up @@ -80,7 +80,7 @@ Remember that Postgres checks shared buffers first before it checks your compute

## View LFC metrics with EXPLAIN ANALYZE

You can also use `EXPLAIN ANALYZE` with the `FILECACHE` option to view LFC cache hit and miss data. Installing the `noen` extension is not required. For example:
You can also use `EXPLAIN ANALYZE` with the `FILECACHE` option to view LFC cache hit and miss data. Installing the `neon` extension is not required. For example:

```sql {6,12,16,22}
EXPLAIN (ANALYZE,BUFFERS,PREFETCH,FILECACHE) SELECT COUNT(*) FROM pgbench_accounts;
Expand Down
Loading

0 comments on commit d6968bf

Please sign in to comment.