It's strongly recommended to fine tune your PostgreSQL installation according to the hardware of the server. A good place to start is this general PostgreSQL tuning page: General PostgreSQL Tips.

The following parameters at a minimum should be touched:

max_connections

Max connections in PostgreSQL should at least be modified past their default. A good starting value is 200 on even modest hardware. As your needs grow, this number should be adjusted and re-evaluated carefully.

When you adjust max_connections, you are very likely to overrun shared memory allowed by the kernel (per process). You can employ the following strategy to figure out how to increase it (or if it needs to be increased).

First, put your new settings in place, and try to start postgresql. If you receive a message like the following, you know that you need to increase the parameter. If the service starts ok, then everything is fine. If you see the following message, make note of the request size (3067224064 in the message below), as you will need that later.

2013-04-30 16:21:30 MDT HINT:  This error usually means that PostgreSQL's request for a shared memory segment
exceeded your kernel's SHMMAX parameter.  You can either reduce the request size or reconfigure the kernel with
larger SHMMAX.  To reduce the request size (currently 3067224064 bytes), reduce PostgreSQL's shared memory usage,
perhaps by reducing shared_buffers or max_connections.                                                                      
        If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter,
in which case raising the request size or reconfiguring SHMMIN is called for.                                        
        The PostgreSQL documentation contains more information about shared memory configuration.                  
   ...fail!                                                                                                        

The following commands can be used to make the shared memory setting persist across reboots, and activate in the currently running kernel. Plug in a number equal to or larger than the request size that postgresql mentioned in its error output.

    size=<<<NUMERIC_SIZE_HERE>>>
    SYSCTLCONF=/etc/sysctl.d/90-landscape.conf              # filename is arbitrary
    sudo sh -c "echo kernel.shmmax = $size > $SYSCTLCONF"   # to make it persist across boots
    sudo sysctl -p $SYSCTLCONF                              # to activate the change

LDS/PostgresqlTuning (last edited 2017-03-16 22:36:14 by davidpbritton)