Design (LLD) distributed search engine - Machine CodingSubhahu Jain·Jan 15, 2023·8 min readTable of contentsIssues in Above Design1️⃣ Singleton Implementation Is NOT Thread-SafeCurrent CodeProblemsSolution2️⃣ servers List Is Not Thread-Safe (Critical)CurrentConcurrent Failure ScenariosOutcomesExpectedSolution3️⃣ RoundRobinStrategy Is NOT Thread-SafeCurrentProblemReal Production SymptomSolution4️⃣ Health Is Checked Too Late (Routing Bug)CurrentIssuesCorrect BehaviorSolution5️⃣ LeastConnections Strategy Is Logically BrokenCodeProblemsConcurrency BugSolution6️⃣ No Session Persistence ImplementationFeature ClaimedRealityMissingSolution7️⃣ Observer Pattern for Health Is IncompleteProblemReal SystemsSolution8️⃣ No Fault Tolerance for Load Balancer ItselfSingle Point of FailureMissingSolution9️⃣ Decorator & Proxy Patterns Are Claimed but Not AppliedClaimedRealitySolution🔟 No Backpressure or Overload ProtectionMissingFailure ModeSolution1️⃣1️⃣ No Metrics = Blind SystemMissing MetricsSolution1️⃣2️⃣ Request Object Is Undefined (Design Gap)CurrentMissingSolutionJavaScriptPythonGeneral ProgrammingProgramming BlogsAWS