Skip to content

Conversation

@rileyseaburg
Copy link
Contributor

Problem

Production deployments are failing with:

organization's memory limit exceeded: ******* requires 2048M memory

Root Cause

During rolling deployments, Cloud Foundry needs memory for:

  1. Staging the app (building the droplet)
  2. Running existing instances
  3. Starting new instances during the rolling deployment

Even with --strategy rolling, if the org doesn't have enough total memory quota, staging fails before rolling deployment even starts.

Solution

This PR applies the same fix that was implemented for the sidekiq worker in commit 48b4e42:

  1. Scale down to 1 instance before deploying to free up memory quota
  2. Deploy with rolling strategy
  3. Scale back up to original instance count after successful deployment
  4. Scale back up even if deployment fails to restore service

Changes

  • Modified .circleci/deploy.sh to:
    • Check current instance count before deployment
    • Scale down to 1 instance if running multiple instances
    • Scale back up after successful deployment
    • Scale back up after failed deployment (best effort)

Testing

This approach has been proven to work for the sidekiq worker deployment since December 2025 (commit 48b4e42).

Related

Copilot AI review requested due to automatic review settings January 13, 2026 17:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses memory quota issues during Cloud Foundry rolling deployments by implementing a scale-down-deploy-scale-up pattern. The changes prevent deployment failures caused by insufficient memory quota when Cloud Foundry needs to simultaneously stage the application and run both old and new instances.

Changes:

  • Modified .circleci/deploy.sh to capture current instance count before deployment
  • Implemented automatic scale-down to 1 instance before deployment if multiple instances are running
  • Added scale-up logic to restore original instance count after successful deployment
  • Added scale-up logic to restore service even when deployment fails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ota exceeded

Similar to the sidekiq worker fix in commit 48b4e42, scale down the main
touchpoints web app to 1 instance before deploying, then scale back up after
successful deployment. This prevents 'organization's memory limit exceeded'
errors during rolling deployments when the org doesn't have enough quota for
multiple instances during the staging/deployment process.
@rileyseaburg rileyseaburg force-pushed the fix-web-deploy-memory-quota branch from 930ce30 to 6250c86 Compare January 14, 2026 14:53
Sidekiq workers don't need the Rust widget renderer (it's only used for
rendering widgets in the web app). Without SKIP_WIDGET_RENDERER=true,
the app crashes on startup because the native library isn't found.

This was causing the sidekiq worker to crash with:
'WidgetRenderer native library not found'

Now the deploy script sets this env var before pushing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants