Clustering
The SAMA server supports clustering out of the box.
You can run a cluster across separate physical servers or on the same machine with multiple SAMA-server instances.
Setup Steps
Section titled “Setup Steps”-
Run dependent services:
Use the following command to start MongoDB, Minio, and Redis:
Terminal window docker-compose up -
Run multiple SAMA-server instances:
- Option 1: Open multiple terminal consoles, run
npm run start
in each, and set theAPP_PORT
environment variable to a different value for each instance. - Option 2: Remove the
APP_PORT
environment variable and run multiple nodes via PM2:
Terminal window pm2 start pm2.config.cjsThe number of instances is defined by the
instances
value in thepm2.config.cjs
file. - Option 1: Open multiple terminal consoles, run
-
Set up Nginx balancer:
- Open
nginx/default.conf
and provide the IP addresses of all running nodes.
If running locally, use your machine’s private IPs, notlocalhost
or127.0.0.1
. - Start the Nginx balancer:
Terminal window docker-compose -f docker-compose-nginx-balancer.yml up --build - Open
-
Access the cluster:
The cluster will be available on port
9000
. Point your SAMA-client to this port for testing.