total.js

total.js application scaling capabilities


From the high level standpoint
In the case if I would like to optimize totaljs application. Is there a possibility I can use a proxy server to load balance requests across multiple instances of totaljs on different ports each on its own thread or even a separate machine on lan without deep dive into the totaljs core?

I've tried a dummy method such as. It appears to be working, but maybe there's a better way.

const ports = [8080, 8081, 8082, 8084]

cp = require('child_process')

ports.forEach((port) => {
    cp.fork('./debug.js', [port])
})

//debug.js
options = {};   
options.port = process.argv[2];

Is there any more details how most efficiently I can execute multiple totaljs instances to serve the single point of entrance in order to improve or at least have an option to decrease the overload of the single thread.


Solution

  • You can use Total.js Cluster:

    https://docs.totaljs.com/latest/en.html#api~FrameworkCluster

    Implementation is very easy:

    require('total.js');
    
    const options = {};
    options.ip = '0.0.0.0';
    
    // Run the framework in the cluster
    F.cluster.http(4, 'release', options);
    

    IMPORTANT: Total.js products aren't optimized for the cluster.