Student: Savitha and Jane
Due Date: November 24, 2025
Files Created:
backend/Dockerfile- Node.js container with health checksfrontend/Dockerfile- Multi-stage build with Nginxbackend/.dockerignore- Optimized build contextfrontend/.dockerignore- Optimized build contextdocker-compose.yml- Complete orchestration
Services Containerized:
- MySQL Database (port 3306)
- MongoDB Sessions (port 27017)
- Zookeeper (port 2181)
- Kafka Broker (ports 9092, 9093)
- Kafka UI (port 8080)
- Backend API - Traveler/Owner/Property/Booking services (port 4000)
- Frontend React App (port 3000)
Features:
- Health checks for all services
- Dependency management (depends_on with conditions)
- Persistent volumes for data
- Network isolation
- Environment variable configuration
Files Created:
k8s/00-namespace.yaml- Namespace isolationk8s/01-configmap.yaml- Application configurationk8s/02-secrets.yaml- Sensitive data managementk8s/03-mysql-deployment.yaml- MySQL StatefulSetk8s/04-kafka-deployment.yaml- Kafka + Zookeeperk8s/05-backend-deployment.yaml- Backend with HPAk8s/06-frontend-deployment.yaml- Frontend with LoadBalancerk8s/07-mongodb-deployment.yaml- MongoDB for sessions
Kubernetes Features:
- Namespace for isolation (
airbnb) - ConfigMaps for configuration
- Secrets for sensitive data
- PersistentVolumeClaims for data persistence
- Health probes (liveness & readiness)
- Resource limits and requests
- Horizontal Pod Autoscaler (HPA) for backend and frontend
- Service discovery and networking
- Auto-scaling: 2-5 replicas based on CPU/memory
Service Communication:
- All services can communicate via ClusterIP services
- Backend connects to MySQL, MongoDB, and Kafka
- Frontend exposed via LoadBalancer
Scaling Demonstration:
- Backend: 2-5 replicas (CPU 70%, Memory 80% threshold)
- Frontend: 2-5 replicas (CPU 70%, Memory 80% threshold)
Documentation:
DOCKER_KUBERNETES_SETUP.md- Complete setup guide
Files Created:
backend/config/kafka.js- Kafka producer and configurationbackend/kafka/consumers.js- Consumer implementationsdocker-compose.kafka.yml- Standalone Kafka setupKAFKA_SETUP.md- DocumentationLAB2_KAFKA_STATUS.md- Status and verification
Topics Implemented:
booking-request- Traveler → Owner flowbooking-status-update- Owner → Traveler flow
Flow 1: Booking Creation
Traveler → POST /api/bookings/request
↓
Database: Insert booking (status: PENDING)
↓
Kafka Producer: Publish to "booking-request" topic
↓
Owner Consumer: Receives notification
↓
Owner sees new booking in dashboard
Flow 2: Booking Status Update
Owner → PUT /api/bookings/owner/:id/accept
↓
Database: Update booking (status: ACCEPTED)
↓
Kafka Producer: Publish to "booking-status-update" topic
↓
Traveler Consumer: Receives notification
↓
Traveler sees status update
Code Integration:
- Producer in
bookingController.js: createBooking()publishes booking requestsacceptBooking()publishes status updatescancelBookingOwner()publishes status updates- Owner consumer listens for booking requests
- Traveler consumer listens for status updates
- Graceful error handling
- Server initialization with Kafka
Testing:
- Kafka running on Docker Compose
- Backend connected and publishing events
- Consumers receiving and processing messages
- Kafka UI accessible for monitoring
Files Created/Modified:
backend/server.js- MongoDB session configurationk8s/07-mongodb-deployment.yaml- MongoDB K8s deployment- Updated
docker-compose.ymlwith MongoDB service - Updated Kubernetes ConfigMap and Secrets
Implementation:
- MongoDB as database: Using MongoDB 7.0
- Sessions stored in MongoDB:
- Integrated
connect-mongowithexpress-session - Sessions persist in MongoDB collection
- TTL: 24 hours
- Lazy session updates (touchAfter: 24h)
- Encryption with session secret
- Passwords encrypted:
- Using
bcryptjswith salt rounds: 10 - All passwords hashed before storage
- Verified in
travelerController.jsandownerController.js - Password comparison using
bcrypt.compare()
Database Architecture:
- MySQL: Application data (travelers, owners, properties, bookings, favorites)
- MongoDB: Session storage (user sessions with encryption)
- Hybrid approach for optimal performance
Session Storage Features:
- Automatic session cleanup (TTL)
- Encrypted session data
- Persistent across server restarts
- Scalable with MongoDB clustering
Requirements:
- Install Redux Toolkit and React-Redux
- Create Redux store structure
- Implement auth slice (JWT token management)
- Implement properties slice (search, filter, details)
- Implement bookings slice (create, status, favorites)
- Connect React components to Redux
- Test with Redux DevTools
Estimated Time: 2-3 hours
Requirements:
- Install Apache JMeter
- Create test plans for:
- User authentication (login/signup)
- Property data fetching
- Booking processing
- Run tests with 100, 200, 300, 400, 500 concurrent users
- Collect metrics:
- Response times
- Throughput
- Error rates
- Create graphs and analysis
- Write performance report
Estimated Time: 2-3 hours
Lab1_DistributedSystem/
├── backend/
│ ├── config/
│ │ ├── database.js
│ │ └── kafka.js NEW
│ ├── controllers/
│ │ ├── bookingController.js Updated (Kafka)
│ │ ├── ownerController.js (bcrypt)
│ │ └── travelerController.js (bcrypt)
│ ├── kafka/
│ │ └── consumers.js NEW
│ ├── Dockerfile NEW
│ ├── .dockerignore NEW
│ ├── package.json Updated
│ └── server.js Updated (Kafka + MongoDB)
│
├── frontend/
│ ├── Dockerfile NEW
│ └── .dockerignore NEW
│
├── k8s/
│ ├── 00-namespace.yaml NEW
│ ├── 01-configmap.yaml NEW
│ ├── 02-secrets.yaml NEW
│ ├── 03-mysql-deployment.yaml NEW
│ ├── 04-kafka-deployment.yaml NEW
│ ├── 05-backend-deployment.yaml NEW
│ ├── 06-frontend-deployment.yaml NEW
│ └── 07-mongodb-deployment.yaml NEW
│
├── docker-compose.yml NEW
├── docker-compose.kafka.yml NEW
├── DOCKER_KUBERNETES_SETUP.md NEW
├── KAFKA_SETUP.md NEW
├── LAB2_KAFKA_STATUS.md NEW
└── LAB2_PROGRESS.md NEW
# Start all services
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f
# Stop
docker-compose downAccess:
- Frontend: http://localhost:3000
- Backend API: http://localhost:4000
- Kafka UI: http://localhost:8080
# Deploy everything
kubectl apply -f k8s/
# Check status
kubectl get all -n airbnb
# Port forward services
kubectl port-forward service/frontend-service 3000:80 -n airbnb
kubectl port-forward service/backend-service 4000:4000 -n airbnb
# View logs
kubectl logs -f deployment/backend -n airbnbAll services running: docker-compose ps
Backend health: curl http://localhost:4000/health
Kafka UI accessible: http://localhost:8080
MongoDB running: docker exec -it airbnb-mongodb mongosh
All pods ready: kubectl get pods -n airbnb
HPA configured: kubectl get hpa -n airbnb
Services created: kubectl get svc -n airbnb
PVCs bound: kubectl get pvc -n airbnb
Topics created: booking-request, booking-status-update
Producer publishing events
Consumers receiving messages
Console logs showing Kafka activity
Sessions stored in MongoDB Passwords encrypted with bcrypt Session persistence working MongoDB health checks passing
All work committed to lab2 branch:
5b7fee06- Kafka integration implementation1d3ce444- Kafka status documentation0230a9ac- Docker and Kubernetes setup97eb8e27- MongoDB integration for sessions
-
Redux Implementation
- Set up Redux Toolkit
- Create slices for auth, properties, bookings
- Connect components
- Test with DevTools
-
JMeter Testing
- Create test plans
- Run load tests (100-500 users)
- Generate graphs
- Write analysis report
-
Final Report
- Architecture diagrams
- Implementation details
- Screenshots
- Performance analysis
Authors: Savitha and Jane Last Updated: November 20, 2025 Branch: lab2