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

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.

Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) Matt Butler Matt Butler Software Engineer @ AWS 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. zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. Victor Denisov Victor Denisov Developer legrab legrab I'll fill this later Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture 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. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking.

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