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
restart: ${RESTART_POLICY}
security_opt:
- no-new-privileges:true
pids_limit: 100
Copy link
Member

Choose a reason for hiding this comment

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

Can we document in this PR why pids_limit is not appropriate for Postgres + our default max connections? (Just so we can trace the history here.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where would we document that? In the general docs at https://docs.mattermost.com/deployment-guide/server/deploy-containers.html?

Copy link
Member

Choose a reason for hiding this comment

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

I think even a description in this pull request that explains the context would suffice as a "paper trail" for why we're making the change. That being said, given our new understanding of the impact of this setting, it might even be worth an FAQ in the container docs linked above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point 👍 I've updated the PR description and submitted mattermost/docs#8695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants