Background jobs are commonly used in theNode.js for maintaining and keep the main application fast, butthere is a problem in traditional queue base system, wherevalidation is done afterwards. Means if there any invalid orpolicy-violating job then they firstly stored into queue andrejected in worker execution time. This results in unnecessaryconsumption of CPU cycles, memory, queue space. For solve thisissue we introduce Centralized Rule Engine (CRE) that validatejob on admission-time before queue insertion. We applied 10-point gatekeeping mechanism where we centralized Rule Registryand Zod schema validation to make ensure that invalid or non-compliant jobs are immediately rejected. We analyzed CRE with2 models: reactive worker-side validation and API-level schema-only validation under high load scenario of 10,000 jobs and 50concurrent workers. The CRE achieved a throughput of 1642.25jobs per second which is significantly faster than reactive models(1036.05 jobs per second) and schema-only model (1469.55 jobsper second). By rejecting invalid job early, we saved CPU powerand unnecessarily queue state expansion in Redis wassuccessfully prevented. Ultimately, CRE is an admission timerule enforcement system which improve the efficiency, it reducesthe worker-side complexity and gives the synchronous feedbackto producer which address a major gap in asynchronous Node.jsarchitectures. However, the synchronous admission layerintroduces marginal overhead under low-load scenarios whereinvalid job frequency is minimal.
Mali et al. (Sun,) studied this question.