Back to all docs

Development vs Production: Resource Requirements

Date: 2025-11-08 Context: Ahaia Music web app setup

Key Lesson

Development and production modes in Node.js/Next.js have drastically different resource requirements.

Development Mode (npm run dev)

Memory Usage: ~250 MB for Next.js

Process Tree:

npm → shell → node (next CLI) → next-server

Use Case: Local development, coding, testing changes

Not suitable for: Production hosting or resource-constrained environments

Production Mode (npm run buildnpm start)

Memory Usage: ~50-100 MB for Next.js

Build Step:

Runtime:

Server Specs Context

Current Server:

Development Mode:

Production Mode:

Deployment Strategy

Option 1: Build Elsewhere

# On dev machine (laptop/CI/CD)
npm install
npm run build

# Copy .next/, public/, package.json to server
rsync -av .next/ server:/path/to/app/.next/
rsync -av public/ server:/path/to/app/public/

# On server
npm install --production  # Only prod dependencies
npm start

Option 2: Add Temporary Swap

# On server (before build)
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# Build
npm run build

# Remove swap (optional)
sudo swapoff /swapfile
sudo rm /swapfile

Option 3: Stop Services During Build

# Free up memory
sudo systemctl stop <other-services>

# Build
npm run build

# Restart services
sudo systemctl start <other-services>

# Run production
npm start

Recommendations

  1. For Active Development: Use a separate dev machine or add swap
  2. For Production Hosting: Current server specs are fine
  3. Build Process: Do builds off-server or with temporary resources
  4. Runtime: Production mode is lightweight enough for this server

Memory Breakdown Example

Development (npm run dev):

next dev processes:     250 MB
Other services:         500 MB
System:                 150 MB
Available:              ~10 MB  ⚠️ Too tight!

Production (npm start):

next start process:      80 MB
Other services:         500 MB
System:                 150 MB
Available:              180 MB  ✅ Comfortable

Takeaway: Don't judge production requirements by development memory usage. They're completely different workloads.