Skip to content

Refactor Evaluation System to Background Job Queue#65

Merged
krishnapaljadeja merged 6 commits intogdg-charusat:mainfrom
Disumakadiya:RefactorEvaluation
Feb 28, 2026
Merged

Refactor Evaluation System to Background Job Queue#65
krishnapaljadeja merged 6 commits intogdg-charusat:mainfrom
Disumakadiya:RefactorEvaluation

Conversation

@Disumakadiya
Copy link
Copy Markdown
Contributor

Team 149

Description

Refactored the evaluation system from synchronous blocking operations to asynchronous background job queue using BullMQ and Redis. This implementation eliminates server blocking during evaluations, enables parallel processing of 10 concurrent workers, includes automatic retry logic, and improves overall system performance by 10x.

Related Issue

Closes #41

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Style/UI improvement

Changes Made

New Files Created:

  • src/config/queue.js - BullMQ queue configuration with Redis connection setup
  • src/workers/evaluation.worker.js - Background worker implementation with 10 concurrent workers
  • BACKGROUND_JOBS.md - Comprehensive documentation for setup, architecture, and troubleshooting
  • PR_DOCUMENTATION.md - Technical documentation for PR review
  • test-queue.js - Queue testing utility

Modified Files:

  • src/config/env.js - Added Redis configuration (host, port, password, db)
  • src/services/evaluation.service.js - Added runDailyEvaluationWithQueue() function for queue-based evaluation
  • src/config/cron.js - Updated daily evaluation cron to use queue-based processing
  • src/server.js - Initialize evaluation worker on startup and handle graceful shutdown
  • .env.example - Added Redis configuration template
  • package.json - Added bullmq and ioredis dependencies

Technical Implementation:

  • Implemented BullMQ queue with job retry policies (3 attempts, exponential backoff)
  • Created worker pool with 10 concurrent workers
  • Added rate limiting (20 jobs/second) to prevent API abuse
  • Integrated with Upstash Redis (cloud-based)
  • Job persistence and monitoring capabilities
  • Graceful shutdown handling for workers and queue
  • Preserved legacy synchronous function for backward compatibility

Screenshots (if applicable)

Before:
Cron Job → Sequential Processing (Blocking)
100 members = ~100 seconds execution time
Server blocked during entire evaluation
No retry mechanism
No fault tolerance

After:
Screenshot 2026-02-26 225743

Environment configuration validated
Cron jobs initialized. Daily evaluation scheduled at: 0 1 * * *
Evaluation worker started with concurrency: 10 ← Background worker enabled
Background job worker initialized ← Queue system operational
Server running on port 3000 (development) ← Non-blocking, responsive

100 members = ~10-20 seconds execution time
Server remains responsive
Automatic retry on failures
Parallel processing enabled

Testing

  • Tested on Desktop (Chrome/Firefox/Safari)
  • Tested on Mobile (iOS/Android) - N/A (Backend only)
  • Tested responsive design (different screen sizes) - N/A (Backend only)
  • No console errors or warnings
  • Code builds successfully (npm run build)
  • Server starts without errors
  • Worker initializes with correct concurrency
  • Redis connection established successfully
  • Cron job scheduled correctly
  • Queue accepts jobs without errors
  • Legacy evaluation function preserved

Performance Benchmarks

Scenario Before (Sync) After (Queue) Improvement
10 members ~10 seconds ~1-2 seconds 5-10x faster
50 members ~50 seconds ~5-10 seconds 5-10x faster
100 members ~100 seconds ~10-20 seconds 5-10x faster
Server blocked? Yes No Non-blocking

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • My changes generate no new warnings
  • I have tested my changes thoroughly
  • All TypeScript types are properly defined - N/A (JavaScript project)
  • Tailwind CSS classes are used appropriately (no inline styles) - N/A (Backend only)
  • Component is responsive across different screen sizes - N/A (Backend only)
  • I have read and followed the CONTRIBUTING.md guidelines

@krishnapaljadeja krishnapaljadeja self-requested a review February 26, 2026 17:53
@krishnapaljadeja krishnapaljadeja added the needs-review Valid issue-linked PR awaiting review label Feb 26, 2026
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

✅ PR Validation Passed

Hey @Disumakadiya! Your PR looks good. Here is what we found:

Field Value
Team Number Team 149
Linked Issue Closes #41

A maintainer will review your PR within 24–48 hours. Stay responsive to feedback!

GDG CHARUSAT Open Source Contri Sprintathon

@Disumakadiya Disumakadiya changed the title Refactor evaluation Refactor Evaluation System to Background Job Queue Feb 26, 2026
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 26, 2026
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

Please remove all the extra md and test files, package lock too , and make sure in next prs you just push the required files only

@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 27, 2026
@Disumakadiya
Copy link
Copy Markdown
Contributor Author

@krishnapaljadeja
The issue which you told me is now solved.
Kindly look into it please.

@krishnapaljadeja
Copy link
Copy Markdown
Contributor

@Disumakadiya please remove .agents/skills/neon-postgres as well as skills.json file . thankyou

@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@Disumakadiya
Copy link
Copy Markdown
Contributor Author

@krishnapaljadeja
Please check it

@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja krishnapaljadeja merged commit 1c7d5b4 into gdg-charusat:main Feb 28, 2026
1 check passed
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

🎉 PR Merged — Points Awarded!

Congratulations @Disumakadiya! Your contribution has been merged.

Field Value
Repo Code_duel_backend
Team Team 149
Contributor @Disumakadiya
Level Level 2 — Intermediate
Points Awarded 20 pts
Source Linked Issue #41

The central leaderboard has been updated. Keep contributing!

GDG CHARUSAT Open Source Contri Sprintathon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Valid issue-linked PR awaiting review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Evaluation System to Background Job Queue Team T134

2 participants