Neon is Generally Available! Serverless Postgres with branching to boost your development velocity.Read more
Guides/Caching

Add the Neon PolyScale integration

Set up a global database cache with Neon's PolyScale integration

Update Regarding PolyScale Support

The PolyScale Serverless product will be discontinued as of June 1st, 2024. For an overview of what this means and the reasoning behind the decision, we encourage you to read the official PolyScale announcement.

In alignment with this change, Neon will sunset its integration with PolyScale. While the instructions for utilizing the PolyScale integration will continue to be accessible to existing users for the time being, they will be phased out from the Neon documentation in the near future. We recommend users begin planning for this transition and explore alternative solutions.

For support and guidance through this transition, please feel free to reach out to our Support team or the Neon community on Discord.

With PolyScale you can easily cache your data globally through its low-latency regional edge network. Enjoy benefits like speedy access to your data from anywhere in the world, reduced load on your database, and improved slow query performance. A PolyScale global cache is also an alternative to cross-regional replication without the added complexity. No coding or infrastructure changes are required to use PolyScale. You can have it up and running in just a few minutes.

Adding the PolyScale integration to a Neon project automatically creates a global cache and provides you with a PolyScale connection string, which you can use in your application as a direct replacement for your Neon connection string.

By default, PolyScale automatically caches all queries that pass through its platform. This means that when you connect through PolyScale, any queries you run will be automatically cached. Requests are routed to the closest Point Of Presence (POP) location where your query results are cached for low latency access.

note

The PolyScale integration creates a cache for the read-write compute endpoint associated with the primary branch of your Neon project. It does not cache queries for read-only compute endpoints (read replicas) or non-primary branches. If you want to set up a cache for those, please refer to the manual PolyScale setup instructions.

For more information about PolyScale, see How PolyScale works.

To get started with the Neon PolyScale integration, follow the instructions below.

Prerequisites

  • A Neon account and project. For instructions, see Sign up.
  • A database on the primary branch of your Neon project. See Create a database.

Add the PolyScale integration

To add the PolyScale integration to your Neon project:

  1. In the Neon Console, navigate to the Integrations page for your project.

  2. Locate the PolyScale integration and click Add to open the Add PolyScale drawer. Integrations page showing PolyScale

  3. Under How to add, click Sign in, and sign in to PolyScale using your Google, GitHub, or email account. If you do not have a PolyScale account, you can create one. PolyScale offers a free plan and no credit card is required. PolyScale sign in

  4. Select the desired PolyScale Workspace and click Authorize Access to allow Neon to access read and write caches on PolyScale. PolyScale authorize access

    After the integration is added, you are returned to the Integrations page. Locate the PolyScale integration and click Manage if the Manage PolyScale drawer is not already opened.

    PolyScale manage drawer

    Here, you can view information about your newly created PolyScale cache and copy the PolyScale connection string. Use this connection string in place of your Neon connection string in your application.

    note

    The Neon serverless driver is not compatible with a PolyScale integration, as it only supports a direct connection to a Neon database. Use a standard Postgres driver such as node-postgres instead.

    You might notice the drop-down menus for Database and Role. If you have multiple databases and roles on the primary branch of your Neon project, use the drop-down menus to select the database and role you want to connect with. Your selections will be reflected in the PolyScale connection string.

    note

    To ensure your cache remains current, always use the PolyScale connection string. Modifying your database directly through a Neon connection string or the Neon SQL Editor can result in an outdated cache.

View your PolyScale cache

You can access your PolyScale cache directly from the Neon PolyScale integration.

  1. In the Neon Console, navigate to the Integrations page.
  2. Locate the PolyScale integration and click Manage to open the Manage PolyScale drawer.
  3. Click the View cache in PolyScale link. You are directed to PolyScale where you will be required to log in if not logged in already.

Purging your PolyScale cache

Occasionally, it may be necessary to purge your PolyScale cache. For example, you may want to purge your cache after modifying your data directly without using the PolyScale connection string, which can result in an outdated cache.

To purge your PolyScale cache:

  1. In the Neon Console, navigate to the Integrations page.
  2. Locate the PolyScale integration and click Manage to open the Manage PolyScale drawer.
  3. Click Purge PolyScale cache.

Purging the cache purges all cached data globally.

Remove the PolyScale integration

To remove the PolyScale integration:

  1. In the Neon Console, navigate to the Integrations page.
  2. Locate the PolyScale integration and click Manage to open the Manage PolyScale drawer.
  3. Click Remove integration.

Removing the integration deletes the cache and terminates all current connections using the PolyScale connection string.

How PolyScale works

When you use a PolyScale connection string in your application, PolyScale automatically caches the queries that pass through its platform via the connection string. That means any queries you run using the PolyScale connection string are cached, by default.

PolyScale identifies caching opportunities by recognizing and remembering patterns in query traffic. New queries typically begin to see cache hits on or about the third query. For more information on this topic, see Time To First Hit, in the PolyScale documentation.

After queries from your application start passing through PolyScale, you can monitor traffic and caching behavior on the Observability tab in PolyScale. For instructions, see Observability, in the PolyScale documentation.

For additional information about the PolyScale platform, please refer to the PolyScale documentation.

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more detail, see Getting Support.

Last updated on

Edit this page
Was this page helpful?