Skip to content

Conversation

d-gubert
Copy link
Member

@d-gubert d-gubert commented Aug 27, 2025

This PR has been created via Cursor Agent Web Interface

feat: Add Traefik load balancer for host-based development

Proposed changes (including videos or screenshots)

This PR introduces a new development setup for running a Traefik Docker container that load balances multiple Rocket.Chat instances running directly on the host machine (e.g., with yarn dev).

The existing Traefik configurations in the repository primarily support Rocket.Chat instances running within Docker containers. This new setup addresses the need for developers to:

  • Test high availability (HA) scenarios with multiple development instances.
  • Debug load balancing behavior while using hot-reloading for host-based development.
  • Simulate production load balancing more accurately in a development environment.

Key features of this new setup:

  • Host Networking: Utilizes network_mode: "host" for the Traefik container, allowing it to directly access Rocket.Chat instances running on localhost (e.g., 127.0.0.1:3000, 127.0.0.1:3002). This simplifies the setup by avoiding complex Docker networking for the Rocket.Chat instances themselves.
  • Dynamic Configuration: Uses Traefik's file provider with watch: true to automatically reload routing and service configurations when changes are made to config/rocketchat.yml.
  • WebSocket Compatibility: Configures sticky sessions using cookies to ensure WebSocket connections (e.g., /websocket, /sockjs) maintain affinity with a single backend Rocket.Chat instance.
  • Health Checks: Includes health checks (/api/info) for backend instances to ensure traffic is only routed to healthy servers.
  • Comprehensive Documentation: A new README.md provides step-by-step instructions, architecture overview, troubleshooting, and references to official Traefik documentation.
  • Helper Script: A start-instances.sh script is included to easily launch multiple Rocket.Chat instances on different ports.

All new files are contained within a new directory development/traefik-host-dev/, ensuring no impact on existing configurations.

Issue(s)

N/A

Steps to test or reproduce

  1. Navigate to the new directory: cd development/traefik-host-dev
  2. Start the Traefik container: docker-compose up -d
  3. In your Rocket.Chat project root, start multiple Rocket.Chat instances in separate terminals:
    • yarn dev (starts on port 3000 by default)
    • PORT=3002 yarn dev
    • PORT=3003 yarn dev
      (Alternatively, use the provided helper script: ../start-instances.sh 3)
  4. Edit development/traefik-host-dev/config/rocketchat.yml and uncomment the additional server URLs (e.g., http://127.0.0.1:3002, http://127.0.0.1:3003). Traefik will automatically reload.
  5. Access the load-balanced Rocket.Chat application via http://localhost:3000 (or http://rocketchat.localhost:3000 if you configured your hosts file).
  6. Access the Traefik dashboard at http://localhost:8080 (or http://traefik.localhost:8080).
  7. Verify that traffic is being distributed across your running Rocket.Chat instances and that WebSocket connections maintain sticky sessions (e.g., by inspecting the rocketchat-server cookie in browser developer tools).

Further comments

This setup provides a valuable tool for developers to test high availability and load balancing scenarios in a flexible and efficient manner, without the overhead of containerizing their development instances. It's an optional addition that enhances the development workflow for specific testing needs. The detailed README.md serves as a comprehensive guide for its usage and configuration.


Open in Cursor Open in Web

Copy link
Contributor

cursor bot commented Aug 27, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Copy link
Contributor

dionisio-bot bot commented Aug 27, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project
  • This PR has an invalid title

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Aug 27, 2025

⚠️ No Changeset found

Latest commit: eba26ab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.14%. Comparing base (4f1e315) to head (eba26ab).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #36816   +/-   ##
========================================
  Coverage    66.13%   66.14%           
========================================
  Files         3303     3303           
  Lines       110994   110994           
  Branches     21047    21047           
========================================
+ Hits         73410    73414    +4     
+ Misses       34911    34908    -3     
+ Partials      2673     2672    -1     
Flag Coverage Δ
e2e 57.30% <ø> (+0.01%) ⬆️
unit 71.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Successfully merging this pull request may close these issues.

4 participants