Replies: 7 comments 17 replies
-
1. Localhost + DigitalOceanBlitz started in production mode. laptop in Boston. Digital Ocean in NYC1
Results
|
Beta Was this translation helpful? Give feedback.
-
2. Vercel + Digital OceanVercel in aws us-east-1, digitalocean in nyc1
With a bit more load or time, we start seeing 500's with the error This is because for serverless deploys, each request can make another database connection, so the 22 database connections allotted by DO quickly runs out. This should be solved by proxying the database with a layer that manages the connection pooling. Relevant prisma docs: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/deployment#serverless-faas w/DigitalOcean's Connection Pool (pgBouncer)DigitalOcean can setup pgBouncer to do connection pooling for us. They say that they can support 5000 connections per pool this way. Great! With pooling:
There used to errors with some variant of: Closed in prisma/prisma#2520 ConclusionDigitalOcean Postgres now works well with Prisma, just be sure to enable the connection pool on DigitalOcean! |
Beta Was this translation helpful? Give feedback.
-
3. Just DigitalOceanRan Blitz on a DigitalOcean droplet + connected to DigitalOcean DB from setup 1 and 2. Everything in digitalocean nyc1
Results:
This is an 4x faster than Vercel, and competitive with setup 1. It's not a fair test exactly because both resources are in DigitalOcean, but theoretically, the Vercel setup should be close by (DO NYC1 to aws iad1). A more fair test will be conducted with RDS in the exact same datacenter as Vercel. Stay tuned :) |
Beta Was this translation helpful? Give feedback.
-
Hey! Matheus from Vercel here. I found a few misleading points on your analysis: Your Vercel deployment is far away from your database. As per your GitHub profile, I see you live in Boston, and given you got good results from localhost, I assume you're using the NYC DO region. Your Vercel deployment, however, is not configured to be deployed any specific region (no Therefore, your results with Vercel are misleading (or, arguably, invalid): each database query results in a roundtrip across the US! I've opened a PR on your repo with a fix: dajinchu/blitz-perftest#1 👍 Another point you mentioned:
The networking between cloud providers is known to be optimised – it's on their best interest to have an optimal connection to other providers. I have a VM on DO NYC1, and you can see that the latency to the nearest Vercel Edge (
That's less than the latency from my laptop to my Wi-Fi router 😄 Furthermore, this is also misleading:
If I understand their docs correctly, you're telling Artillery to do 20 req/s ( Regarding the high rate of errors, that seems to be a limitation of Digital Ocean, given you mentioned that it's not possible to apply the fix that Prisma suggested. |
Beta Was this translation helpful? Give feedback.
-
4. AWS EC2 + RDSBaseline setup with RDS. No RDS proxy running. Equivalent to setup 3. Everything in us-east-1.
|
Beta Was this translation helpful? Give feedback.
-
5. Vercel + RDSVercel and RDS both in us-east-1.
Just about the same as setup 2. The difference could be due to being in the same datacenter instead of 2 nearby datacenters, but there are other uncontrolled variables like switching db from DO to RDS. Since we know that Vercel and RDS are in the same datacenter, I wonder why we're still 50ms slower than the EC2 solution. Could just be the time it takes to go through Vercel's load balancing/routing infrastructure? With enough load, we're able to 500 the server due to running out of connections, so we need to setup a connection pooling solution. Unfortunately, RDS Proxy can only connect within the same VPC, afaik. Will continue digging. |
Beta Was this translation helpful? Give feedback.
-
@dajinchu question: is the Couple other things I'd also like to know:
|
Beta Was this translation helpful? Give feedback.
-
Would love to start some discourse on how to get great performance out of a serverless deployment and how database choice factors into that. This is in the hopes of guiding our users towards the pit of success with a "performant by default" solution.
An Experiment
I'm going to test out a bunch of different configurations and get some numbers. Note that this experiment is more about nextjs/prisma/serverless than Blitz 🤷 I couldn't find any existing info on this, so here we are. Maybe the Vercel people know more.
Controlled variables:
blitz new
db.product.findMany({ first: 4 })
and 500 if error is thrown.I will post about each database setup in a reply here.
Repo: https://github.com/dajinchu/blitz-perftest
Keeping Score
Beta Was this translation helpful? Give feedback.
All reactions