Skip to content

Conversation

@mathemancer
Copy link
Contributor

@mathemancer mathemancer commented Oct 2, 2025

Fixes #4831

This adds a WEB_CONCURRENCY environment variable to the docker compose setup. Appropriate settings are documented in the same file.

TODO

  • Document the variable for from scratch installs.
  • Document the variable for 1-click deployments.

Technical details

This variable is used by Gunicorn to set the number of workers, and is the only variable supported for changing concurrency settings, other than the variable to set all command-line arguments. The default I chose is "3", which is reasonable as long as Mathesar is running with at least 1 logical core available. This will improve the situation, but only a bit. Basically, with the sync worker type, we need one worker per concurrent request. So, this takes us from 1 to 3 🎊 .

Long-term, we should try to use the gevent worker type, since that enables async I/O, and Mathesar is extremely I/O, rather than CPU, bound. However, that doesn't work (easily) in Psycopg2, which means it doesn't affect Explorations. It does improve (fix, really) performance in the non-exploration part of the codebase, but I didn't want to make the change in the current limited-QA situation. If we decide we are not going to try to squeeze this PR into 0.6.0, then I think we should make that change as well, to get the benefits in the parts of the codebase where we're using psycopg3.

This is yet another spot where our failure to deal with Explorations and the deprecated SQLAlchemy part of the codebase is biting us.

To test this, you can just load big tables in multiple browsers manually, or follow the instructions in #4841 .

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@mathemancer mathemancer changed the base branch from develop to release-0.6.0 October 2, 2025 08:25
@mathemancer
Copy link
Contributor Author

@zackkrida This is mergable, and doesn't harm the 1-click deployments, but I think it would make sense to document setting this variables for those scenarios as well. I'm not sure how the users should determine the number of vCPUs on various platforms, which is a prerequisite to setting this variable correctly.

@mathemancer mathemancer requested a review from zackkrida October 2, 2025 08:28
@mathemancer mathemancer added the pr-status: review A PR awaiting review label Oct 2, 2025
@mathemancer mathemancer marked this pull request as ready for review October 2, 2025 08:29
@mathemancer mathemancer mentioned this pull request Oct 2, 2025
7 tasks
Comment on lines 218 to 221
# expose:
# - "5432"
ports:
- "5432:5432"
Copy link
Member

Choose a reason for hiding this comment

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

Is this change necessary, I rememeber making a conscious decision to not expose the postgres port to the host.

Copy link
Member

Choose a reason for hiding this comment

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

@mathemancer was this for testing purposes or some other reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! Great eye, @Anish9901 . That was for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, reverted in 1682771

@pavish
Copy link
Member

pavish commented Oct 2, 2025

@mathemancer @zackkrida This commit cb2504f adds a default value for WEB_CONCURRENCY env variable for the from-scratch script based installation.

zackkrida and others added 2 commits October 2, 2025 14:47
Co-authored-by: Anish Umale <umaleanish120@gmail.com>
@zackkrida zackkrida merged commit 50b55b0 into release-0.6.0 Oct 3, 2025
125 checks passed
@zackkrida zackkrida deleted the config_web_concurrency branch October 3, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-status: review A PR awaiting review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gunicorn concurrency issues Long DB Queries are blocking Hangs and timeouts when more than one user logged in

5 participants