Bad Perfomance When Running Multiple Dedicated Hosts for Multiplayer Game Using Headless Browser

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi everyone,

    I'm working on a multiplayer game in Construct 3 where I've implemented a custom WebSocket plugin for handling connections instead of the built-in Multiplayer plugin.

    The setup involves running dedicated "hosts" for different rooms on a server, using Playwright (Node.js) to launch headless Chromium instances that load the game's index.html and act as the host.

    Basic flow:

    Each room is created by launching a new browser instance, navigating to the game URL with a room parameter (e.g. index.html?name=room1), and letting the game handle the WebSocket server logic inside Construct.

    Clients connect via WebSocket to these hosts.

    This works fine for a single room:

    Idle RAM: ~400–600 MB per instance

    CPU usage: ~4%

    However, when scaling to 2+ rooms, resource usage skyrockets:

    The second room pushes CPU usage to ~40%.

    By the third room, the server (an 8-CPU VPS) starts slowing down significantly.

    Even with optimizations like --disable-gpu, --disable-webgl, a very small viewport (1×1), and disabling unnecessary Chromium features, each additional instance increases CPU usage exponentially instead of linearly.

    There are no clients connected yet — these are just idle hosts.

    Has anyone successfully run multiple dedicated hosts like this (using headless browsers or an alternative approach)?

    What tools or architectures did you use?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No headless browser, but multiple C3 instances without problems: construct.net/en/forum/construct-3/general-discussion-7/construct-multiplayer-187718

    Could be an issue with your implementation (Playwright, node, etc...)

  • Are you using a vps or something similar?

  • Are you using a vps or something similar?

    No. Are you?

    If you are, what is the VPS you're running on?

    Bear in mind that vCPUs in a VPS are considerably slower than your typical CPU core in a desktop PC or laptop. VPS are virtualized environments that provide access to only a small portion of the actual CPU, which can lead to spikes up to 100% utilization even during relatively light CPU tasks.

    For example, don't be fooled by "8 vCPU cores", expecting it to perform similarly to a 13th-gen Intel Core i5-13420H (8 cores). The performance difference between these two can be significant (several orders of magnitude).

    You should perform a CPU benchmark on both your local PC and your VPS to at least have an idea of what to expect.

    For improved CPU performance, consider bare-metal hosting (instead of a VPS). It provides direct access to the physical CPU hardware, rather than sharing pooled CPU in the form of "vCPUs".

    Edit: I'm curious to what your reasoning is for having dedicated hosts vs letting player hosts their own rooms?

    An alternative would be to have player hosts rooms while all peers (and the host) are also connected to a central server for the features that need to be centralized (not synchronized at 30 times a second).

  • I'm using dedicated servers because it's kind of an IO game, and I also know what an 8 vCPU server at 1.1 GHz can and can't handle. I solved it by running multiple rooms inside the same game instance, so I only need to launch the game once to run all the servers, and that solved all the performance problems.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)