By Merouane
Hello,
I’m currently facing two challenges with my DigitalOcean database setup:
Prisma Connection Pooling
I’m using Prisma with DigitalOcean’s database services and would like guidance on whether I should define or adjust the connection pool size. Should I explicitly configure Prisma’s connection pool settings to optimize performance, or is the default configuration sufficient for handling spikes in workload? High Load Average
During peak usage hours (about 8 hours daily), the load average on my database server spikes up to 18. The current configuration is 8 GB RAM, 2 vCPUs, and 60 GB Disk. Should I upgrade my database configuration to handle these spikes better? If so, what would be the best configuration to manage high, consistent workloads effectively? Thank you for your assistance. I look forward to your recommendations.
Best regards,
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey there! 👋
For DigitalOcean Managed Databases, you could actually handled your connection pooling on the database level directly. Since DigitalOcean provides managed PgBouncer, you should use that instead:
# Your connection string should look like this for PgBouncer
DATABASE_URL="postgresql://user:password@db-postgresql-nyc1-xxxxx-pooler.db.ondigitalocean.com:25060/defaultdb?sslmode=require"
You can learn more about managing connection pools with DigitalOcean Managed Databases here:
Regarding the resources, before upgrading, you can check if slow queries are the culprit. You can visit the cluster’s Settings > Logs (or Logs & Queries). The Currently running queries section tracks all of the PostgreSQL cluster’s open connections, potentially resulting in queries with long durations.
If you find slow queries, you can optimize them by adding appropriate indexes. For example, if you’re frequently searching or sorting by ticket_number
, you can add an index like this:
CREATE INDEX idx_ticket_number ON tickets (ticket_number);
To learn more about indexes, you can check out this tutorial here.
https://www.digitalocean.com/community/tutorials/how-to-use-explain-to-analyze-queries-in-postgresql
If after query optimization and connection pooling are in place, and you still see high load on the database, then you can consider upgrading the resources:
So my recommendation would be:
DigitalOcean Managed Databases handle a lot of the optimization automatically, so focus on application-level optimizations first!
Another thing that you can consider here is caching. For example you can use a Redis cache for frequently accessed data that doesn’t change often to reduce the load on the database:
Feel free to share more details about your application and database usage, and I will be happy to provide more specific recommendations!
- Bobby
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.