β¨ What this app does:
This app allows users to send and receive notifications between devices in real-time by entering and sharing messages.
- β‘ Socket.io - Enables instant updates for all connected clients without page refreshes
- π§ Redis - Powers rate limiting capabilities
- βοΈ React + Vite - Delivers a responsive frontend with fast dev environment performance
- π Express - Facilitates communication between frontend clients
- π§ͺ Mocha/Chai/Sinon - Provides comprehensive testing for backend API routes
- Install NPM and Node.js (required for the project).
# 1. Clone the project
git clone https://github.com/zhtgeneral/LoadbalanceRealtime.git
# 2. Install dependencies
cd LoadbalanceRealtime
cd client && npm install
cd ../server && npm installnpm run startThis will:
- π³ Launch a Redis Docker container
- π Start the Express backend server
npm run devThis will:
- βοΈ Launch the React development server
Warning: Make sure backend server is closed, or this will not work.
npm run test:integrationThis will:
- β Run all Mocha/Chai test suites
- π Verify API endpoint functionality
- Go to Oracle Cloud Infrastructure
- Create Compute Instance π€
- Change Image to Ubuntu Linux (24.04 was used) π§
- Keep ARM Shape VM.Standard.E2.1.Micro π¦Ύ
- Create VNIC (unique for each instance) to connect compute instance to VCN (can be reused) π
- βNote: VCN needs an additional rule added later
- Generate public and private key pair or reuse existing public key ποΈπ:
- To get a fresh set of keys:
- Click download private key and download public key
- Public key looks like
ssh-key-<YYYY-MM-DD>.key.pub - Private key looks like
ssh-key-<YYYY-MM-DD>.key
- Public key looks like
- Click download private key and download public key
- Or paste an existing public key into the input and click add
β οΈ Note: This changes the SSH process slightly
- To get a fresh set of keys:
- Move the keys outside of the project location πβ‘οΈ
β οΈ Note: The keys cannot be accessed later so do it now
- Specify Boot Volume to 50GB π¦
Now you have created the compute instance. To make it accessible to the public, we need to add an extra rule:
- Go to Virtual cloud networks π
- Select the VCN that was used
- Subnets πΈοΈ
- Subnet name
- Security πͺͺ
- Default security list for security name
- Security rules
- Add Ingress Rules π²
- Source CIDR as 0.0.0.0/0 and Desination port range as 5173
Once the compute instance is setup correctly, we can check that public IP is accessible using this command in powershell by running this command:
tnc <public-ip> -p 22β If the instance is running, it should return
ComputerName : <public-ip>
RemoteAddress : <public-ip>
RemotePort : 22
InterfaceAlias : Wi-Fi
SourceAddress : <public-ip>
TcpTestSucceeded : TrueOnce the VM is verified, we can enter the VM using the SSH key. Before we can enter, we will need to change the security settings. These are the steps:
- Right click
ssh-key-<YYYY-MM-DD>.key - Properties
- Security
- Edit Group or user names
- Remove Authenticated Users and Users from permitted users π¨βπ©βπ§βπ¦π§ β
- Make sure Administrators and SYSTEM are left ππ€β
βWarning: You must complete the previous step and change the security settings on the ssh key, or else the next step won't work.
The steps to enter the VM are:
- Run powershell in admin mode π
- Run this command
ssh -i ./ssh-key-<autogenerated-date>.key ubuntu@<public-ip>β Once you have entered the VM, it should show something like this.
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-1026-oracle x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of <Weekday> <Mon> <day> XX:XX:XX UTC 2025
System load: 0.06 Processes: 120
Usage of /: 4.0% of 47.39GB Users logged in: 0
Memory usage: 23% IPv4 address for ens3: 10.0.0.186
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: <Weekday> <Mon> <day> XX:XX:XX 2025 from <IP Address>
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.β Note: if the previous security step was skipped, you will get an error saying
Bad permissions. Try removing permissions for user: NT AUTHORITY\\Authenticated Users (S-1-5-11) on file D:/.../ssh-key-<YYYY-MM-DD>.key.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for './ssh-key-<YYYY-MM-DD>.key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "./ssh-key-<YYYY-MM-DD>.key": bad permissions
ubuntu@<Public IP>: Permission denied (publickey).From here, we need to:
- π³ install docker and docker-compose
- π¦ clone the app
- π run the app in docker
Use these commands to run the app.
# Install Docker
sudo apt update
sudo apt install -y docker.io
# Enable and start Docker
sudo systemctl enable docker
sudo systemctl start docker
# Install Docker Compose plugin
sudo apt install -y docker-compose
# Add user to Docker group (optional: avoid using sudo every time)
sudo usermod -aG docker $USER
newgrp docker
# Clone the repository
git clone https://github.com/zhtgeneral/LoadbalanceRealtime.git
cd LoadbalanceRealtime
# Run the app in docker
docker compose up -dβ If successful, you should be able to visit the app at
http://<Public IP>:5173If you use a second terminal and SSH into the VM with the first running the app, you will see this. Notice that the memory usage is higher.
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-1026-oracle x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of <Weekday> <Mon> <day> XX:XX:XX UTC 2025
System load: 0.02 Processes: 146
Usage of /: 8.6% of 47.39GB Users logged in: 1
Memory usage: 68%βββ IPv4 address for ens3: 10.0.0.186
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
96 updates can be applied immediately.
76 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
1 additional security update can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm
Last login: <Weekday> <Mon> <day> XX:XX:XX 2025 from <IP Address>On a second terminal with the first running the app, run this to check if the ports are correct:
docker psβ It should return
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fcd671db7d9e loadbalancerealtime_frontend "docker-entrypoint.sβ¦" 7 minutes ago Up 7 minutes 0.0.0.0:5173->5173/tcp, :::5173->5173/tcp loadbalancerealtime_frontend_1
1483af47b51d loadbalancerealtime_backend "docker-entrypoint.sβ¦" 7 minutes ago Up 7 minutes 0.0.0.0:3001->3001/tcp, :::3001->3001/tcp loadbalancerealtime_backend_1
b7e50e40045c redis:7 "docker-entrypoint.sβ¦" 7 minutes ago Up 7 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp loadbalancerealtime_redis_1Run this command in the VM to watch logs in real time.
docker compose logs -fRun this command in the VM to stop all containers.
docker compose downRun this command in the VM to restart all containers.
docker compose up -d