Skip to main content

Google Cloud Platform

Deploy QuickRTC to Google Cloud Compute Engine with automated scripts.

Prerequisites

  1. Install Google Cloud SDK
  2. Authenticate with Google Cloud:
    gcloud auth login
  3. Set your project:
    gcloud config set project YOUR_PROJECT_ID
  4. Enable required APIs:
    gcloud services enable compute.googleapis.com
    gcloud services enable containerregistry.googleapis.com

Quick Deploy

# Clone the repository
git clone https://github.com/vidya-hub/QuickRtc.git
cd QuickRtc/quickrtc-example

# Set your project ID
export GCP_PROJECT_ID=your-project-id

# 1. Build and push Docker images to GCR
./run.sh gcloud-build

# 2. Create a VM instance
./run.sh gcloud-create-vm

# 3. Deploy the application
./run.sh gcloud-deploy

Your app will be available at https://EXTERNAL_IP (with self-signed certificate).

GCloud Commands

CommandDescription
./run.sh gcloud-buildBuild & push images to Google Container Registry
./run.sh gcloud-create-vmCreate a GCE VM instance with firewall rules
./run.sh gcloud-deployDeploy containers to the VM
./run.sh gcloud-sshSSH into the VM
./run.sh gcloud-logs [container]View container logs (default: quickrtc-server)
./run.sh gcloud-stopStop all containers on VM
./run.sh gcloud-statusShow VM status and external IP
./run.sh gcloud-sslSetup Let's Encrypt SSL certificate
./run.sh gcloud-delete-vmDelete the VM (destructive!)

Environment Variables

VariableDescriptionDefault
GCP_PROJECT_IDGoogle Cloud project ID(from gcloud config)
GCP_REGIONGCP regionus-central1
GCP_ZONEGCP zoneus-central1-a
GCE_INSTANCE_NAMEVM instance namequickrtc-vm
GCE_MACHINE_TYPEVM machine typee2-medium
GCE_SERVICE_ACCOUNTService account email(optional)

Production SSL with Let's Encrypt

For production with a custom domain:

# 1. Point your domain DNS to the VM's external IP
# 2. Run SSL setup
DOMAIN=rtc.yourdomain.com EMAIL=you@example.com ./run.sh gcloud-ssl

This will:

  • Install certbot
  • Obtain Let's Encrypt certificate
  • Configure nginx for HTTPS
  • Setup auto-renewal

Architecture

Internet

├── HTTPS (443) ──► nginx ──► client (React app)
│ └──► server (Socket.IO/signaling)

└── UDP (40000-40100) ──► server (WebRTC media)

Containers Running

ContainerPurposePorts
quickrtc-nginxReverse proxy, SSL termination80, 443
quickrtc-clientReact static filesInternal
quickrtc-servermediasoup signaling & media3000, 40000-40100/UDP

Firewall Rules

The gcloud-create-vm command automatically creates these firewall rules:

RulePortsProtocolDescription
quickrtc-http80, 443, 3000TCPHTTP/HTTPS access
quickrtc-webrtc40000-49999UDP/TCPWebRTC media ports

Cost Estimation

ResourceSpecEst. Monthly Cost
VM (e2-medium)2 vCPU, 4GB RAM~$25-35
Static IP1 IP~$3
EgressVaries~$0.12/GB
Cost Optimization
  • Use preemptible VMs for development (~70% cheaper)
  • Choose a region close to your users
  • Consider committed use discounts for production

Scaling

Vertical Scaling

Upgrade VM size for more capacity:

# Stop VM
gcloud compute instances stop quickrtc-vm --zone=us-central1-a

# Resize
gcloud compute instances set-machine-type quickrtc-vm \
--machine-type=e2-standard-4 \
--zone=us-central1-a

# Start VM
gcloud compute instances start quickrtc-vm --zone=us-central1-a

Horizontal Scaling

For large deployments (100+ users):

  1. Use a load balancer for HTTP traffic
  2. Deploy multiple server instances
  3. Use Redis for session sharing
  4. Implement room-based sharding

Troubleshooting

VM not accessible

# Check VM status
./run.sh gcloud-status

# SSH into VM
./run.sh gcloud-ssh

# Check firewall rules
gcloud compute firewall-rules list

Container crashes

# View logs
./run.sh gcloud-logs quickrtc-server
./run.sh gcloud-logs quickrtc-nginx

# SSH and check Docker
./run.sh gcloud-ssh
docker ps -a
docker logs quickrtc-server

WebRTC not working

  1. Verify UDP ports are open in firewall
  2. Check ANNOUNCED_IP matches external IP
  3. Test UDP connectivity:
    nc -u -v EXTERNAL_IP 40000

SSL certificate issues

# SSH into VM
./run.sh gcloud-ssh

# Check certificate status
sudo certbot certificates

# Renew manually
sudo certbot renew

Cleanup

To delete all resources:

# Delete VM (this will prompt for confirmation)
./run.sh gcloud-delete-vm

# Delete firewall rules manually if needed
gcloud compute firewall-rules delete quickrtc-http quickrtc-webrtc

# Delete container images
gcloud container images delete gcr.io/PROJECT_ID/quickrtc-server
gcloud container images delete gcr.io/PROJECT_ID/quickrtc-client
gcloud container images delete gcr.io/PROJECT_ID/quickrtc-nginx