Mastodon: Split sidekiq queues into different containers. Tune postgresql. Set threads and concurrency on web and streaming.

This commit is contained in:
Víðir Valberg Guðmundsson 2022-12-02 23:10:15 +01:00
parent 97e5f264f9
commit 759ea93dd3
2 changed files with 95 additions and 20 deletions

View File

@ -0,0 +1,20 @@
# DB Version: 14
# OS Type: linux
# DB Type: oltp
# Total Memory (RAM): 16 GB
# Connections num: 300
# Data Storage: hdd
listen_addresses = '*'
max_connections = 300
shared_buffers = 4GB
effective_cache_size = 12GB
maintenance_work_mem = 1GB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 4
effective_io_concurrency = 2
work_mem = 6990kB
min_wal_size = 2GB
max_wal_size = 8GB

View File

@ -16,16 +16,40 @@
src: files/configs/mastodon/env_file.j2 src: files/configs/mastodon/env_file.j2
dest: "{{ services.mastodon.volume_folder }}/env_file" dest: "{{ services.mastodon.volume_folder }}/env_file"
- name: upload vhost config for root domain - name: Upload vhost config for root domain
template: template:
src: files/configs/mastodon/vhost-mastodon src: files/configs/mastodon/vhost-mastodon
dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}" dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}"
- name: Copy postgresql config
copy:
src: files/configs/mastodon/postgresql.conf
dest: "{{ services.mastodon.volume_folder }}/postgres_data/postgresql.conf"
- name: set up mastodon - name: set up mastodon
docker_compose: docker_compose:
project_name: mastodon project_name: mastodon
pull: yes pull: yes
definition: definition:
x-sidekiq: &sidekiq
image: "tootsuite/mastodon:{{ services.mastodon.version }}"
restart: always
env_file: "{{ services.mastodon.volume_folder }}/env_file"
depends_on:
db:
condition: "service_healthy"
redis:
condition: "service_healthy"
networks:
- postfix
- external_services
- internal_network
volumes:
- "{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system"
healthcheck:
test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
version: '3' version: '3'
services: services:
db: db:
@ -70,6 +94,8 @@
volumes: volumes:
- "{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system" - "{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system"
environment: environment:
MAX_THREADS: 10
WEB_CONCURRENCY: 3
VIRTUAL_HOST: "{{ services.mastodon.domain }}" VIRTUAL_HOST: "{{ services.mastodon.domain }}"
VIRTUAL_PORT: "3000" VIRTUAL_PORT: "3000"
VIRTUAL_PATH: "/" VIRTUAL_PATH: "/"
@ -95,30 +121,59 @@
redis: redis:
condition: "service_healthy" condition: "service_healthy"
environment: environment:
DB_POOL: 15
VIRTUAL_HOST: "{{ services.mastodon.domain }}" VIRTUAL_HOST: "{{ services.mastodon.domain }}"
VIRTUAL_PORT: "4000" VIRTUAL_PORT: "4000"
VIRTUAL_PATH: "/api/v1/streaming" VIRTUAL_PATH: "/api/v1/streaming"
sidekiq: # sidekiq-default-push-pull: DB_POOL = 25, -c 25 for 25 connections
image: "tootsuite/mastodon:{{ services.mastodon.version }}" sidekiq-default-push-pull:
restart: always <<: *sidekiq
env_file: "{{ services.mastodon.volume_folder }}/env_file" command: bundle exec sidekiq -c 25 -q default -q push -q pull
command: bundle exec sidekiq -c 32
environment: environment:
DB_POOL: 32 DB_POOL: 25
depends_on:
db: # sidekiq-default-pull-push: DB_POOL = 25, -c 25 for 25 connections
condition: "service_healthy" sidekiq-default-pull-push:
redis: <<: *sidekiq
condition: "service_healthy" command: bundle exec sidekiq -c 25 -q default -q pull -q push
networks: environment:
- postfix DB_POOL: 25
- external_services
- internal_network # sidekiq-pull-default-push: DB_POOL = 25, -c 25 for 25 connections
volumes: sidekiq-pull-default-push:
- "{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system" <<: *sidekiq
healthcheck: command: bundle exec sidekiq -c 25 -q pull -q default -q push
test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] environment:
DB_POOL: 25
# sidekiq-push-default-pull: DB_POOL = 25, -c 25 for 25 connections
sidekiq-push-default-pull:
<<: *sidekiq
command: bundle exec sidekiq -c 25 -q push -q default -q pull
environment:
DB_POOL: 25
# sidekiq-push-scheduler: DB_POOL = 5, -c 5 for 5 connections
sidekiq-push-scheduler:
<<: *sidekiq
command: bundle exec sidekiq -c 5 -q push -q scheduler
environment:
DB_POOL: 5
# sidekiq-push-mailers: DB_POOL = 5, -c 5 for 5 connections
sidekiq-push-mailers:
<<: *sidekiq
command: bundle exec sidekiq -c 5 -q push -q mailers
environment:
DB_POOL: 5
# sidekiq-push-ingress: DB_POOL = 10, -c 10 for 10 connections
sidekiq-push-ingress:
<<: *sidekiq
command: bundle exec sidekiq -c 10 -q push -q ingress
environment:
DB_POOL: 10
networks: networks:
external_services: external_services: