Skip to main content

Managed vs self-managed PostgreSQL on Digital Ocean

Horacio de Oro
Author
Horacio de Oro
Available to help you find and implement the right solution for your business. Expert on Google Cloud and AWS Architecture, Security, Kubernetes, Django, Python, PostgreSql.

Schedule a free consultation at 👉 calendly.com 👈

TL;DR
#

Managed PostgreSQL is more expensive if we consider resources being assigned (CPU+RAM+DISK), but Digital Ocean provides features that makes availability and maintainability much easier compared to self-managed.

For testing and development environment, and proof of concepts, and if costs is very important, it can makes sense to choose the self-managed approach.

Overall comparison
#

Managed PostgreSQL
#

  • General
    • 1 GB RAM
    • 1vCPU
    • 10 GB Disk
    • PostgreSQL 15
    • 15€/mo
  • PROS:
    • Automatic updates
    • Daily point-in-time backups
    • High availability with automated failover (extra cost)
    • Read-only nodes (extra cost)
    • End-to-end security
    • Cluster metrics and alerting
  • CONS:
    • Impossible to SSH into instance
    • Some restrictions (available extensions, PostgreSQL versions, etc)

Self-managed PostgreSQL
#

  • General
    • 1 GB RAM
    • 1 vCPU
    • 25GB Disk
    • PostgreSQL 16 (or any version, it’s up to you)
    • $7/mo
  • PROS:
    • Full control
  • CONS:
    • Managing a database instances requires knowledge, experience and time.

Managed PostgreSQL
#

This is how managed PostgreSQL looks like in the UI.

List of instances
#

managed-pgsql.png

Logs and queries
#

managed-log-and-queries.png

User and database management
#

managed-user-db.png

Some database details
#

managed-other.png

Benchmark
#

Managed PostgreSQL
#

root@ubuntu-bench$ pgbench --host=private-db-PostgreSQL-fra1-88363-do-user-14767703-0.b.db.ondigitalocean.com --port=25060 --username=doadmin --initialize --foreign-keys --scale=100 defaultdb 
done in 48.29 s (drop tables 0.03 s, create tables 0.01 s, client-side generate 25.40 s, vacuum 0.97 s, primary keys 16.61 s, foreign keys 5.27 s).
done in 42.72 s (drop tables 0.04 s, create tables 0.01 s, client-side generate 26.23 s, vacuum 1.09 s, primary keys 10.25 s, foreign keys 5.10 s).
done in 44.63 s (drop tables 0.03 s, create tables 0.01 s, client-side generate 25.09 s, vacuum 1.04 s, primary keys 13.37 s, foreign keys 5.08 s).

Actual benchmark:

root@ubuntu-bench$ pgbench --host=private-db-PostgreSQL-fra1-88363-do-user-14767703-0.b.db.ondigitalocean.com --port=25060 --username=doadmin --client=5 --jobs=2 --time 60 --progress=5 defaultdb 
progress: 60.0 s, 524.0 tps, lat 9.531 ms stddev 2.267, 0 failed
progress: 60.0 s, 527.2 tps, lat 9.481 ms stddev 3.165, 0 failed
progress: 60.0 s, 557.0 tps, lat 8.976 ms stddev 3.438, 0 failed

Self-managed PostgreSQL
#

root@ubuntu-bench$ pgbench --host=10.114.0.4 --username=bench --initialize --foreign-keys --scale=100 bench 
done in 22.20 s (drop tables 0.08 s, create tables 0.02 s, client-side generate 10.61 s, vacuum 1.42 s, primary keys 6.46 s, foreign keys 3.61 s).
done in 21.57 s (drop tables 0.08 s, create tables 0.02 s, client-side generate 11.00 s, vacuum 0.93 s, primary keys 6.26 s, foreign keys 3.29 s).
done in 22.77 s (drop tables 0.09 s, create tables 0.01 s, client-side generate 10.87 s, vacuum 1.10 s, primary keys 6.68 s, foreign keys 4.03 s).

Actual benchmark:

root@ubuntu-bench$ pgbench --host=10.114.0.4 --username=bench --client=5 --jobs=2 --time 60 --progress=5 bench 
progress: 60.0 s, 522.8 tps, lat 9.546 ms stddev 3.133, 0 failed
progress: 60.0 s, 450.6 tps, lat 11.075 ms stddev 3.670, 0 failed
progress: 60.0 s, 544.2 tps, lat 9.176 ms stddev 2.091, 0 failed

Results
#

For some reason that I didn’t investigate yet, the performance of the initialization of the benchmark database was very different, but the actual benchmark reported very similar results, both solution provided ~520 tps (5 concurrent clients, 2 threads).


Try Digital Ocean for free 🤑

Sign up and get a $200, 60-day credit to try droplets, managed Postgres, and more…