Project

General

Profile

Actions

User story #2049

closed

It seems that default configurations of postgresql are not optimal. We need to add some optimizations to our packages

Added by Nicolas PERRON about 13 years ago. Updated over 7 years ago.

Status:
Rejected
Priority:
2
Assignee:
-
Category:
Packaging
UX impact:
Suggestion strength:
User visibility:
Effort required:
Name check:
Fix check:
Regression:

Description

The default (out-of-the-box) configuration of Postgres is really not compliant for large (or normal) machines. It uses a really small amount of memory

The location of the file is
/etc/postgresql/8.x/main/postgresql.conf
/var/lib/pgsql/data/postgresql.conf (on a SuSE system)

Suggested values on a large node

Amount of System V shared memory

A reasonable starting value for shared_buffers is 1/4 of the memory in your system

  • shared_buffers = 1GB

Note : you may need to set the proper amount on the system (ok on the default install on the large EC2 machine)

$ sysctl -w kernel.shmmax=1073741824

Ref : http://www.postgresql.org/docs/8.4/interactive/kernel-resources.html#SYSVIPC

Memory for complex operations

Complex query
  • work_mem = 24MB
  • max_stack_depth = 4MB
Complex maintenance (index, vacuum)
  • maintenance_work_mem = 240MB

Write ahead log

Size of the write ahead log
  • wal_buffers = 4MB

Query planner

Gives hint to the query planner about the size of disk cache
Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting
  • effective_cache_size = 1024MB

Suggested values on a not so large node

  • shared_buffers = 128MB
  • work_mem = 8MB
  • max_stack_depth = 3MB
  • maintenance_work_mem = 64MB
  • wal_buffers = 1MB
  • effective_cache_size = 128MB
Actions #1

Updated by Nicolas PERRON almost 13 years ago

  • Status changed from New to Discussion

Should we really have to change postgres configuration ?
Can we really expect better performances ?
What could be the values to set as default configuration ?

Actions #2

Updated by Jonathan CLARKE over 12 years ago

  • Status changed from Discussion to 2
  • Assignee deleted (Nicolas PERRON)
  • Target version changed from 2.3.5 to 2.4.0~alpha7

This is not a fixed issue, and is something we should address in 2.4. We're currently seeing some psql performance problems using a proprietary plugin, and I think the results of that investigation will help us know what we can and can't do to make psql work "out of the box".

Actions #3

Updated by Nicolas PERRON over 12 years ago

This task isn't assigned to anyone.
I'm not sure that we will be able to fix it in time for 2.4.0~alpha7. It requires to have a specification about which postgresql configuration we wants to use by default, at least.

Actions #4

Updated by Nicolas PERRON over 12 years ago

  • Target version changed from 2.4.0~alpha7 to 2.4.0~beta1
Actions #5

Updated by Jonathan CLARKE over 12 years ago

  • Tracker changed from Bug to User story
  • Target version changed from 2.4.0~beta1 to 18
Actions #6

Updated by François ARMAND about 12 years ago

  • Target version changed from 18 to 2.4.0~rc1

I set that one to 2.4.0~beta6 so that we can discuss if we want to address that, and when.

Actions #7

Updated by Jonathan CLARKE about 12 years ago

  • Target version changed from 2.4.0~rc1 to 2.4.0~rc2
Actions #8

Updated by Nicolas CHARLES about 12 years ago

The community, and some of our production servers, have warning messages like :

2012-09-13 17:27:43 CEST LOG:  checkpoints are occurring too frequently (3 seconds apart)
2012-09-13 17:27:43 CEST HINT:  Consider increasing the configuration parameter "checkpoint_segments".

3 seconds is a too short delay, and cause overhead in large operations (like archiving) (http://www.postgresql.org/docs/9.1/static/runtime-config-wal.html)
The default value for checkpoint_segments is 3; it should probably be raised to 6 for a start, to check that there are indeed improvement

checkpoint_segments=6

Similarly, this depend on the shared_buffer value, which has a defaut of 32 MB. We should really increase this value

shared_buffers = 64MB

(this moderate increase prevent the need to change the shmmax)

The maintenance_work_mem determine the available memory for indexes modifications/table modification, which is typically done during archiving report. It default to 16 MB, which is clearly not enough for this use case

maintenance_work_mem=48MB

These value are conservative, to prevent using to much memory from Postgresql

Actions #9

Updated by Nicolas PERRON about 12 years ago

  • Assignee set to Nicolas PERRON

We shouldn't have to modify user's configuration, then a comment next the attribute modified should be added to know that it is not an user configuration.

For each of attributes, we should have a sed like this:

sed "s/^\(NAME_OF_ATTRIBUTE\s\+=\s\+\).*\(#This comment permit Rudder to modify this value\)$/\132MB\t\2/" 

The attribute should be modified if the comment "This comment permit Rudder to modify this value" exist next the variable or added if doesn't exist.

By default, checkpoint_segments and maintenance_work_mem are commented but shared_buffers is not. shared_buffers will not be updated with the above logic.
What should we do with it ?

Actions #10

Updated by Nicolas PERRON about 12 years ago

  • Target version changed from 2.4.0~rc2 to 2.4.0~rc1
Actions #11

Updated by Nicolas PERRON about 12 years ago

As we discussed together Jon and me, this configuration should be set and check by CFEngine and not set by packaging.

And to answer my question:

By default, checkpoint_segments and maintenance_work_mem are commented but shared_buffers is not. shared_buffers will not be updated with the above logic.

What should we do with it ?

It would be more logical to force the set of these attributes if comments are not present and the user will be able to set its own values with adding comments.

Actions #12

Updated by Nicolas CHARLES about 12 years ago

Oh ! I've just notice that we don't have autovacuum enabled by default !
I would allow for collecting deleted lines (not reclaiming their space on disk, but leaving blanks for new entries, preventing the database to grow too much ( http://www.postgresql.org/docs/8.2/static/sql-vacuum.html ) and that would be important linked to #2974

we would probably need these parameters (based on what I read here : http://www.postgresql.org/docs/8.2/static/routine-vacuuming.html http://www.postgresql.org/docs/8.2/static/runtime-config-autovacuum.html )

track_counts = on

autovacuum = on
autovacuum_naptime = 14400 # every 4 hours

I guess everything else could remain by defaultn but i'm not sure if they would fit (the only deletion we do is when we are archiving)
Actions #13

Updated by Nicolas CHARLES about 12 years ago

Nicolas CHARLES wrote:

Oh ! I've just notice that we don't have autovacuum enabled by default !
I would allow for collecting deleted lines (not reclaiming their space on disk, but leaving blanks for new entries, preventing the database to grow too much ( http://www.postgresql.org/docs/8.2/static/sql-vacuum.html ) and that would be important linked to #2974

we would probably need these parameters (based on what I read here : http://www.postgresql.org/docs/8.2/static/routine-vacuuming.html http://www.postgresql.org/docs/8.2/static/runtime-config-autovacuum.html )

> track_counts = on
> 
> autovacuum = on
> autovacuum_naptime = 14400 # every 4 hours
> 

I guess everything else could remain by defaultn but i'm not sure if they would fit (the only deletion we do is when we are archiving)

Hum, actually, there is an autovacuum launched process, even on SLES
Archiving reports lines don't trigger the vacuum afterwards, probably the default values are not as good as expected

Actions #14

Updated by Nicolas CHARLES about 12 years ago

I guess we would need to set the parameter

autovacuum_vacuum_scale_factor=0.1

for it will cause the vacuum to be triggered when 10% of the content has been deleted rather than 20% (default value)

Actions #15

Updated by Nicolas PERRON about 12 years ago

Nicolas PERRON wrote:

As we discussed together Jon and me, this configuration should be set and check by CFEngine and not set by packaging.

And to answer my question:

By default, checkpoint_segments and maintenance_work_mem are commented but shared_buffers is not. shared_buffers will not be updated with the above logic.

What should we do with it ?

It would be more logical to force the set of these attributes if comments are not present and the user will be able to set its own values with adding comments.

To be more precise, we should add the magical comment "This comment permit Rudder to modify this value" if the attribute is commented or using default values

In the packaging, we should add this magical comment and with the system Techniques force the set of these attributes

Actions #16

Updated by Nicolas PERRON about 12 years ago

  • Target version changed from 2.4.0~rc1 to 2.4.0~rc2

This ticket have to be postponed at least to 2.4.0~rc2

Actions #17

Updated by François ARMAND almost 12 years ago

  • Target version changed from 2.4.0~rc2 to Ideas (not version specific)
Actions #18

Updated by Jonathan CLARKE almost 12 years ago

  • Status changed from 2 to New
Actions #19

Updated by Nicolas PERRON almost 12 years ago

  • Project changed from Rudder to 34
  • Category deleted (11)
Actions #20

Updated by Nicolas PERRON over 11 years ago

  • Assignee deleted (Nicolas PERRON)

I've never worked on it

Actions #21

Updated by Benoît PECCATTE over 9 years ago

  • Project changed from 34 to Rudder
  • Category set to Packaging
Actions #22

Updated by Nicolas CHARLES over 7 years ago

  • Status changed from New to Rejected

All of the suggestions/optimizations are documented in Rudder doc (see http://www.rudder-project.org/rudder-doc-4.1/rudder-doc.html#_performance_tuning )

However, it's not so easy to implement them in the packaging, because it depends on:
  • version of postgres
  • server configuration (how much RAM, how much free RAM, how much services, etc)
  • it could break existing user configuration

Plus, we made a lot lot of changes/corrections/optimizations in Rudder itself, so that out-of-the-box config of postgres becomes an issue after a 1000 nodes.

Actions

Also available in: Atom PDF