Claude Code performance

Inefficient Algorithm Causing Request Timeouts

An endpoint that processes data times out when dataset size increases. The algorithm works correctly for small datasets but degrades exponentially with larger inputs. Response time jumps from 100ms to 10+ seconds as data volume grows.

The algorithm is correct but has poor time complexity that wasn't apparent at scale.

Error Messages You Might See

Request timeout after 30 seconds Response time increases exponentially with data size 504 Gateway Timeout with larger datasets
Request timeout after 30 secondsResponse time increases exponentially with data size504 Gateway Timeout with larger datasets

Common Causes

  1. Nested loops creating O(n²) or O(n³) complexity (sorted list checking for each item)
  2. Inefficient search: linear search where binary search should be used
  3. Unnecessary array copying in loop creating O(n²) memory usage
  4. Recursive algorithm without memoization, recalculating same values
  5. Sorting inside loops instead of once before loop

How to Fix It

Profile the slow endpoint with realistic dataset size. Look for nested loops and recursive calls. Use appropriate data structures: HashSet for O(1) lookup, sorted array for binary search. Avoid creating new objects in tight loops. Memoize/cache expensive calculations. Consider pagination: process in batches instead of all at once.

Real developers can help you.

Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. legrab legrab I'll fill this later Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

How to identify O(n²) problems?

Double the input size. If time increases by 4x, likely O(n²). If increases by 2x, likely O(n). If no change, probably O(1).

When should binary search be used?

When searching sorted array/list. O(log n) instead of O(n). If unsorted, sort first (O(n log n)) then binary search.

How to optimize recursive algorithms?

Add memoization (cache results). Fibonacci: instead of recalculating fib(5) multiple times, cache it. Or use iterative approach.

Related Claude Code Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help