Tuning PostgreSQL for PieFed
Every instance will be different but generally speaking the default settings that PostgreSQL has will be Ok to start with but once the instance has been running for a few months the amount of data being stored will mean things start to bog down and some tuning is needed.
https://pgtune.leopard.in.ua will give you a good starting point.
What we use on piefed.social, with 4 CPU cores and 8 GB of RAM is:
synchronous_commit = offwal_writer_delay = 2000msmax_connections = 200shared_buffers = 1GBeffective_cache_size = 4GBmaintenance_work_mem = 1GBcheckpoint_completion_target = 0.9wal_buffers = 16MBdefault_statistics_target = 100random_page_cost = 1.1effective_io_concurrency = 200work_mem = 10MBhuge_pages = offmin_wal_size = 1GBmax_wal_size = 3GBmax_worker_processes = 4max_parallel_workers_per_gather = 2max_parallel_workers = 4max_parallel_maintenance_workers = 2
That’s pretty much what pgtune provided me except work_mem is a bit bigger.
Save this text in a file at /etc/postgresql/14/main/conf.d/piefed.conf.
The “14” part of that path will vary depending on your postgresql version.