Skip to content

Conversation

@hanzei
Copy link
Contributor

@hanzei hanzei commented Jan 26, 2026

Summary

Replace pids_limit with mem_limit for postgres and mattermost services to prevent connection failures under normal load.

Problem

A customer reported PostgreSQL connection failures caused by hitting the pids_limit: 100 constraint. PostgreSQL creates one process per database connection, meaning the database could only handle ~90-95 concurrent connections before exhausting the PID limit. This is too restrictive for production deployments with moderate traffic.

Changes

  • postgres service: Removed pids_limit: 100, added mem_limit: 16G
  • mattermost service: Removed pids_limit: 200, added mem_limit: 4G
  • Added inline comments directing users to enterprise scaling documentation for sizing guidance

Rationale

Memory limits provide better resource protection while allowing PostgreSQL to scale connections naturally based on actual load. The pids_limit approach was overly restrictive and caused operational issues in real-world scenarios.

The default values chosen (16G/4G) are based on typical medium-sized deployment requirements and can be adjusted per the scaling documentation.

Documentation

Inline comments added referencing https://docs.mattermost.com/administration-guide/scale/scaling-for-enterprise.html

Add mem_limit settings with documentation links to help users
configure appropriate memory limits based on their deployment size.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Jan 26, 2026
@hanzei hanzei requested a review from mrckndt January 26, 2026 17:11
@hanzei hanzei changed the title Add memory limits for postgres and mattermost containers Replace pids_limit with memory limits Jan 26, 2026
@hanzei hanzei requested a review from lieut-data January 26, 2026 20:12
@hanzei
Copy link
Contributor Author

hanzei commented Feb 2, 2026

@isacikgoz Can you please review the PR while Marco is out? Thanks!

@hanzei hanzei requested a review from isacikgoz February 2, 2026 11:16
pids_limit: 200
# See https://docs.mattermost.com/administration-guide/scale/scaling-for-enterprise.html
# for guidance on memory limits based on your deployment size.
mem_limit: 4G
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to be a bit low to me, but it's okay for small instances.

@isacikgoz isacikgoz added 3: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3: Reviews Complete All reviewers have approved the pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants