perf: optimize Twenty CRM resource usage

- Reduce defaults: 4 CPU/8GB → 2 CPU/4GB (official min is 2GB)
- Node.js heap: 512MB server, 384MB worker (runtime)
- Build-time heap: 3072MB (only during compilation)
- PG pool: reduce to 5 connections
- PostgreSQL: tune shared_buffers/work_mem/effective_cache_size
- Redis: cap at 64MB with noeviction policy
- Unset NODE_OPTIONS after build to not leak into runtime
This commit is contained in:
MickLesk
2026-02-22 14:48:11 +01:00
parent 5ab302102b
commit fe48d08c69
3 changed files with 28 additions and 6 deletions

View File

@@ -8,8 +8,8 @@ source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func")
APP="Twenty"
var_tags="${var_tags:-crm;business;contacts}"
var_cpu="${var_cpu:-4}"
var_ram="${var_ram:-8192}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-20}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
@@ -51,11 +51,12 @@ function update_script() {
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
$STD corepack enable
$STD corepack prepare yarn@4.9.2 --activate
export NODE_OPTIONS="--max-old-space-size=4096"
export NODE_OPTIONS="--max-old-space-size=3072"
$STD yarn install --immutable || $STD yarn install
$STD npx nx run twenty-server:build
$STD npx nx build twenty-front
cp -r /opt/twenty/packages/twenty-front/build /opt/twenty/packages/twenty-server/dist/front
unset NODE_OPTIONS
msg_ok "Built Application"
msg_info "Running Database Migrations"