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.

Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Matt Butler Matt Butler Software Engineer @ AWS Basel Issmail Basel Issmail ’m a Senior Full-Stack Developer and Tech Lead with experience designing and building scalable web platforms. I work across the full development lifecycle, from translating business requirements into technical architecture to delivering reliable production systems. My work focuses on modern web technologies, including TypeScript, Angular, Node.js, and cloud-based architectures. I enjoy solving complex technical problems and helping teams turn product ideas and prototypes into working platforms that can grow and scale. In addition to development, I often collaborate closely with product managers, business analysts, designers, and QA teams to ensure that solutions align with both technical and business goals. I enjoy working with startups and product teams where I can contribute both as a hands-on engineer and as a technical partner in designing and delivering impactful software.

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