Question

Assistance with Prisma Connection Pooling and Database Load Average Issues

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,

Show comments

Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 22, 2024

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:

https://docs.digitalocean.com/products/databases/postgresql/how-to/manage-connection-pools/#pooling-modes

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:

  1. Current Configuration:
  • 8 GB RAM
  • 2 vCPUs
  • 60 GB Disk
  1. Potential Upgrade:
  • 4 vCPUs
  • 16 GB RAM
  • Keep 60 GB Disk (unless you’re near capacity).

So my recommendation would be:

  1. Enable DO’s managed PgBouncer
  2. Run the slow query analysis
  3. Add appropriate indexes based on findings
  4. Monitor for 24-48 hours
  5. If issues persist, then consider the hardware upgrade

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:

https://docs.digitalocean.com/products/databases/redis/

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

    Become a contributor for community

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    DigitalOcean Documentation

    Full documentation for every DigitalOcean product.

    Resources for startups and SMBs

    The Wave has everything you need to know about building a business, from raising funding to marketing your product.

    Get our newsletter

    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

    The developer cloud

    Scale up as you grow — whether you're running one virtual machine or ten thousand.

    Get started for free

    Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

    *This promotional offer applies to new accounts only.