Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scaling a postgres server to multiple servers

Tags:

Our postgres server is about hitting its capacity and we're looking into adding a second database server. Are there any scaling solutions that are particularly good for a postgres setup?

like image 537
Oliver Kiel Avatar asked Feb 20 '09 18:02

Oliver Kiel


People also ask

Is PostgreSQL scalable?

The PostgreSQL database supports vertical scalability and can run on bigger and faster machines to increase the performance.

How do I scale a database in PostgreSQL?

There are two main ways to scale our database… Horizontal Scaling (scale-out): It's performed by adding more database nodes creating or increasing a database cluster. Vertical Scaling (scale-up): It's performed by adding more hardware resources (CPU, Memory, Disk) to an existing database node.

Does PostgreSQL scale well?

PostgreSQL can scale rather well vertically. The more resources (CPU, memory, disk) that you can make available to your PostgreSQL server, the better it can perform.

Can PostgreSQL scale horizontally?

With Amazon Relational Database Service (Amazon RDS) for PostgreSQL, you can scale a database instance vertically or horizontally. You implement vertical scaling by changing the DB instance type or size (for example, from M to R or from xlarge to 2xlarge), and scale horizontally by creating read replicas.


2 Answers

You are looking at a limited set of choices, very dependent on what your specific requirements are (read-to-write ratios and how tolerant your application is of occasional inconsistent reads [synchronous vs. asynchronous replication? master-slave vs. multi-master?], how strongly connected your tables are [clustering], etc.)

  • http://www.postgresql.org/download/products/3
    • http://pgpool.projects.postgresql.org/
    • http://www.slony.info/

UPDATE

Over six years have elapsed since the original answer. Please refer to the High Availability, Load Balancing, and Replication chapter in the PostgreSQL documentation for the latest solutions available to you.

like image 197
vladr Avatar answered Sep 22 '22 07:09

vladr


Did you check what is your bottleneck? What are the queries that make your server work hard? Maybe it can be tuned better.

If tuning will not help it is often much easier to upgrade a server than to set replication. Adding some disks in RAID1 or RAID10, adding some RAM, more cores and faster processor. A good RAID controller with battery backed cache would make a big difference too.

Replication id good for high availability but often a bigger server will be more cost effective if you have performance problems.

like image 43
Tometzky Avatar answered Sep 22 '22 07:09

Tometzky