{"id":312,"date":"2026-04-30T06:52:56","date_gmt":"2026-04-30T06:52:56","guid":{"rendered":"https:\/\/melento.ai\/blog\/?p=312"},"modified":"2026-04-30T06:52:56","modified_gmt":"2026-04-30T06:52:56","slug":"finding-a-needle-in-a-haystack","status":"publish","type":"post","link":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack","title":{"rendered":"Finding a needle in a haystack"},"content":{"rendered":"<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">When you&#8217;re working in a monolithic legacy codebase spanning hundreds of thousands of lines, finding that one notorious function\u2014or even a single line of code\u2014can feel like searching for a needle in a haystack.<\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">Last year, my team was tasked with a critical mission: <b>stabilize SignDesk to ensure higher uptime and reliability<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">But the problem statement was vague. Where do you begin in such a vast and aging system?<\/p>\n<h2><span style=\"color: #2c5363;\"><b>Observability First<\/b><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">We quickly realized that the first step was <b>observability<\/b><span style=\"font-weight: 400;\">. Without visibility, it&#8217;s like walking into a dark room. So, we started with <\/span><b>Node.js profiling<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">We profiled the production server during peak transaction hours\u20141 hour per session\u2014to identify the functions and lines of code consuming the most CPU time.<\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">What we found was eye-opening.<\/p>\n<h2><span style=\"color: #2c5363;\"><b>Counterintuitive Insights<\/b><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">Contrary to intuition, it wasn\u2019t the large, complex functions that were choking the system. Instead, seemingly harmless, simple functions were spending <b>30\u201340 seconds on the CPU<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">A common culprit? Nested <span style=\"font-weight: 400;\">for<\/span><span style=\"font-weight: 400;\"> loops and <\/span><span style=\"font-weight: 400;\">.find()<\/span><span style=\"font-weight: 400;\"> operations on large arrays.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">At scale, these innocent-looking iterations were <b>crippling server performance<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><span style=\"color: #2c5363;\"><b>The Fix: Smarter Data Structures<\/b><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">The solution was straightforward yet powerful: <b>better data structures<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">We moved from arrays to hash maps. While an array lookup is O(n), a hashmap lookup is O(1)\u2014a game-changer at production scale.<\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">Nested loops that previously hit O(n\u00b2) complexity were now lean and fast. With millions of transactions, this change alone brought CPU spikes down from <b>70\u201380% to a healthy baseline<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">The same function that once hogged the CPU for 30+ seconds now executed in <b>just 2 seconds<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><span style=\"color: #2c5363;\"><span style=\"color: #2c5363;\"><b>Unblocking the Event Loop<\/b><\/span><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">We also discovered several <b>synchronous file I\/O operations<\/b><span style=\"font-weight: 400;\"> that were <\/span><b>blocking the event loop<\/b><span style=\"font-weight: 400;\">. These were converted into <\/span><b>asynchronous calls<\/b><span style=\"font-weight: 400;\">, keeping the JavaScript event loop free and responsive.<\/span><\/p>\n<h2><span style=\"color: #2c5363;\"><b>Separating Concerns<\/b><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">Another performance issue was heavy <b>cron schedulers<\/b><span style=\"font-weight: 400;\"> running during business hours\u2014right alongside critical transaction flows.<\/span><\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">We extracted these into a <b>dedicated microservice<\/b><span style=\"font-weight: 400;\">, allowing the monolith to focus solely on <\/span><b>transactions<\/b><span style=\"font-weight: 400;\">, vastly improving throughput and system reliability.<\/span><\/p>\n<h2><span style=\"color: #2c5363;\"><b>Resilience Through Redundancy<\/b><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">In systems dependent on external vendors, uptime is often out of your hands. If a vendor is down, your product goes down with it.<\/p>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">To address this, we integrated <b>multiple vendors (NSDL &amp; CVL)<\/b><span style=\"font-weight: 400;\"> for the same service and built an <\/span><b>intelligent auto-switch mechanism<\/b><span style=\"font-weight: 400;\">. This system detects vendor downtime in real time and switches to a secondary provider seamlessly\u2014often before users even notice.<\/span><\/p>\n<h2><span style=\"color: #2c5363;\"><b>The Results<\/b><\/span><\/h2>\n<p style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">All these initiatives\u2014profiling, restructuring, async ops, microservices, and intelligent failovers\u2014culminated in a massive win:<\/p>\n<p><span style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\">\u00a0<\/span><b>50% reduction<\/b><span style=\"font-weight: 400;\"> in server resource allocation<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <b>Zero downtime<\/b><span style=\"text-align: justify; font-size: 17px; font-family: 'open sans';\"> during peak transaction months<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <b>Significantly fewer customer complaints<\/b><b><br \/>\n<\/b> <b>Greater confidence across teams<\/b><\/p>\n<p style=\"text-align: center;\"><button class=\"navigate-to-form\"><strong>Book a Demo<\/strong><\/button><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you&#8217;re working in a monolithic legacy codebase spanning hundreds of thousands of lines, finding that one notorious function\u2014or even a single line of code\u2014can feel like searching for a needle in a haystack. Last year, my team was tasked with a critical mission: stabilize SignDesk to ensure higher uptime and reliability. But the problem [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":387,"comment_status":"open","ping_status":"open","sticky":false,"template":"page_templates\/blog-new-3.php","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[59],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-authors"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Finding a needle in a haystack<\/title>\n<meta name=\"description\" content=\"Finding a needle in a haystack\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Finding a needle in a haystack\" \/>\n<meta property=\"og:description\" content=\"Finding a needle in a haystack\" \/>\n<meta property=\"og:url\" content=\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack\" \/>\n<meta property=\"og:site_name\" content=\"Melento\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-30T06:52:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1338\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Srivalli M\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Srivalli M\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack\",\"url\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack\",\"name\":\"Finding a needle in a haystack\",\"isPartOf\":{\"@id\":\"https:\/\/melento.ai\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#primaryimage\"},\"image\":{\"@id\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#primaryimage\"},\"thumbnailUrl\":\"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg\",\"datePublished\":\"2026-04-30T06:52:56+00:00\",\"author\":{\"@id\":\"https:\/\/melento.ai\/blog\/#\/schema\/person\/433bcb0c78564dec9320194c8f82e95a\"},\"description\":\"Finding a needle in a haystack\",\"breadcrumb\":{\"@id\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#primaryimage\",\"url\":\"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg\",\"contentUrl\":\"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg\",\"width\":2560,\"height\":1338,\"caption\":\"Finding a needle in a haystack\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/melento.ai\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Finding a needle in a haystack\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/melento.ai\/blog\/#website\",\"url\":\"https:\/\/melento.ai\/blog\/\",\"name\":\"Melento\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/melento.ai\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/melento.ai\/blog\/#\/schema\/person\/433bcb0c78564dec9320194c8f82e95a\",\"name\":\"Srivalli M\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/melento.ai\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c1618c81ff732fa78529c7d4c0fa89df1596ff358dd5f944ebdf9ec276d51e7f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c1618c81ff732fa78529c7d4c0fa89df1596ff358dd5f944ebdf9ec276d51e7f?s=96&d=mm&r=g\",\"caption\":\"Srivalli M\"},\"url\":\"https:\/\/melento.ai\/blog\/author\/srivalli-mel\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Finding a needle in a haystack","description":"Finding a needle in a haystack","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack","og_locale":"en_US","og_type":"article","og_title":"Finding a needle in a haystack","og_description":"Finding a needle in a haystack","og_url":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack","og_site_name":"Melento","article_published_time":"2026-04-30T06:52:56+00:00","og_image":[{"width":2560,"height":1338,"url":"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg","type":"image\/jpeg"}],"author":"Srivalli M","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Srivalli M","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack","url":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack","name":"Finding a needle in a haystack","isPartOf":{"@id":"https:\/\/melento.ai\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#primaryimage"},"image":{"@id":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#primaryimage"},"thumbnailUrl":"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg","datePublished":"2026-04-30T06:52:56+00:00","author":{"@id":"https:\/\/melento.ai\/blog\/#\/schema\/person\/433bcb0c78564dec9320194c8f82e95a"},"description":"Finding a needle in a haystack","breadcrumb":{"@id":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#primaryimage","url":"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg","contentUrl":"https:\/\/melento.ai\/blog\/wp-content\/uploads\/2026\/04\/images_Tanay-article-1-1-scaled.jpg","width":2560,"height":1338,"caption":"Finding a needle in a haystack"},{"@type":"BreadcrumbList","@id":"https:\/\/melento.ai\/blog\/finding-a-needle-in-a-haystack#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/melento.ai\/blog\/"},{"@type":"ListItem","position":2,"name":"Finding a needle in a haystack"}]},{"@type":"WebSite","@id":"https:\/\/melento.ai\/blog\/#website","url":"https:\/\/melento.ai\/blog\/","name":"Melento","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/melento.ai\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/melento.ai\/blog\/#\/schema\/person\/433bcb0c78564dec9320194c8f82e95a","name":"Srivalli M","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/melento.ai\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c1618c81ff732fa78529c7d4c0fa89df1596ff358dd5f944ebdf9ec276d51e7f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c1618c81ff732fa78529c7d4c0fa89df1596ff358dd5f944ebdf9ec276d51e7f?s=96&d=mm&r=g","caption":"Srivalli M"},"url":"https:\/\/melento.ai\/blog\/author\/srivalli-mel"}]}},"_links":{"self":[{"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/comments?post=312"}],"version-history":[{"count":6,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":389,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/posts\/312\/revisions\/389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/media\/387"}],"wp:attachment":[{"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/media?parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/categories?post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/melento.ai\/blog\/wp-json\/wp\/v2\/tags?post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}