Dynamic uWSGI Configuration Optimization Based on System Resources #2156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
###Overview
This pull request enhances the uWSGI configuration generated by tacticalrmm/management/commands/create_uwsgi_conf.py by dynamically adjusting key parameters (workers, threads, cheaper, socket-timeout, and harakiri) based on the system's CPU count and available RAM. The changes improve scalability and performance, particularly under high agent loads, while maintaining compatibility with smaller systems.
###Motivation
In a production environment with 10 CPUs and 16 GB of RAM, running Tactical RMM with many active agents (like 2.000), I encountered frequent connect() failed (11: Resource temporarily unavailable) errors from NGINX due to uWSGI socket saturation. The original static configuration struggled to handle the load, leading to dropped connections and degraded performance. Through extensive testing, I identified optimized settings that resolved these issues.