Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prisma/accelerate-speed-test
https://github.com/prisma/accelerate-speed-test
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/prisma/accelerate-speed-test
- Owner: prisma
- Created: 2023-01-13T21:14:17.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T16:25:02.000Z (about 1 year ago)
- Last Synced: 2023-12-18T20:16:46.434Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://accelerate-speed-test.vercel.app
- Size: 1.25 MB
- Stars: 16
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Accelerate Speed Test
This app demonstrates the performance benefits of [Accelerate](https://www.prisma.io/data-platform/accelerate?utm_source=accelerate-speedtest), a new product by Prisma. Accelerate provides a global cache with built-in connection pooling.
The Accelerate Speed Test is a Next.js app using Edge API Routes to serve cached data at the edge. When the speed test begins it will start two concurrent tests, one with cache and one without, that will each run as many sequential Prisma `count` operations as they can. The results are streamed to the UI and displayed for comparison.
## Setup
To run the Accelerate Speed Test locally or deploy it yourself, you'll first need a Prisma Data Platform account. [Create one here](https://console.prisma.io/login?utm_source=accelerate-speedtest) if you haven't already.
Next, you'll need a database. The Prisma Schema in this repository uses PostgreSQL, but you can substitute it with another database if desired. Create a new Accelerate project for the database to retrieve an Accelerate connection string.
Once you have an Accelerate connection string, create a `.env` file with `DATABASE_URL` set to your direct database connection and `ACCELERATE_URL` set to the Accelerate connection string. This will allow you to push schema changes to your database directly while using Accelerate in the app. Run `npx prisma db push` to sync the schema changes with your database.
```
DATABASE_URL="postgresql://..."
ACCELERATE_URL="prisma://accelerate.prisma-data.net..."
```You should now be ready to start the app with `npm run dev`. Since the speed test runs a count operation, it can be helpful to load your database with a number of fake records. We used 500,000 LinkOpen entries, but the performance difference gets more dramatic as the number climbs. The more records you add, the more the database has to work to count them, but cache hits will avoid the database altogether and maintain a consistent latency regardless. The latency is also affected by the app's distance from the database. The cache being at the edge maintains stable performance for cache hits regardless of the database proximity.