Why my API was slow (and what actually fixed it) I recently noticed one of my APIs was taking way too long to respond — sometimes 3–4 seconds per request. At first, I thought it was just my code being “messy,” but digging deeper taught me a lot. Here’s what I found: Too many unnecessary DB calls – I was fetching the same data multiple times instead of reusing it. Unoptimized queries – Some queries were scanning entire collections instead of using indexes. Synchronous loops – I was waiting for each call to finish one by one, instead of running them in parallel. After making a few changes: Added proper indexes Used Promise.all for parallel DB calls Cached repeated data where possible Response time went from 3–4 seconds → under 300ms. The biggest takeaway? Sometimes it’s not your code logic, it’s how your code talks to the database and handles tasks. Small adjustments can make a huge difference. #FullStackDeveloper #WebDevelopment #APIDevelopment #BackendDevelopment #NestJS #NextJS #JavaScript #PerformanceOptimization #SoftwareDevelopment
Optimizing API Performance with Indexes and Parallel Calls
More Relevant Posts
-
Blindly parsing API responses with JSON.parse is one of the most common ways to let silent bugs into your codebase. When an API changes a field type from string to number, or drops a required key entirely, JSON.parse won't complain - it never does. You only find out when something breaks in production. Schema validation at the API boundary changes this completely. Here's a simple example using Zod: const UserSchema = z.object({ id: z.string().uuid(), email: z.string().email(), role: z.enum(["admin", "user"]), }); const user = UserSchema.parse(await response.json()); If the API payload doesn't match, you get an immediate, descriptive error - not a mystery undefined three layers deep. This also doubles as living documentation for what your app actually expects from external data. Practical takeaway: treat every external API response as untrusted input. Validate at the boundary, not after the damage is done. Are you already validating API payloads in your projects, or still relying on TypeScript types alone to feel safe? #JavaScript #WebDevelopment #TypeScript #FrontendDevelopment #APIDevelopment #CleanCode
To view or add a comment, sign in
-
Your ORM is quietly killing your API performance - and you might not even notice until it's too late. ORMs are great for scaffolding and CRUD operations. But when you're dealing with hot-path queries - endpoints hit thousands of times per minute - the abstraction cost becomes real. The problem isn't just N+1 queries. It's the overhead of model instantiation, eager loading assumptions, and queries you didn't ask for. Compare these two approaches in Node.js: ORM version: const users = await User.findAll({ include: [{ model: Order }] }); Raw query version: const users = await db.query('SELECT u.id, o.total FROM users u JOIN orders o ON o.user_id = u.id WHERE u.active = true'); The raw query gives you full control - no hidden joins, no unnecessary columns, no bloated result mapping. Practical takeaway - profile your slowest endpoints first. If an ORM-generated query shows up consistently, replace it with a parameterized raw query. Keep ORMs for writes and low-traffic reads. Where do you draw the line between developer convenience and runtime performance in your Node.js services? #nodejs #webdevelopment #backenddevelopment #databaseoptimization #javascript #softwareengineering
To view or add a comment, sign in
-
Count the lines of React 18 code you write for every single form submission: const [isPending, setIsPending] = useState(false) const [error, setError] = useState(null) async function handleSubmit(e) { e.preventDefault() setIsPending(true) try { await save() } catch(e) { setError(e.message) } finally { setIsPending(false) } } Now count the React 19 version: const [state, formAction, isPending] = useActionState(saveAction, null) One line. Same behavior. Automatic pending state, error handling, and reset. That's what React 19 is: the same React, with the boilerplate removed. Here's everything that changed: ⚡ Actions + useActionState — async mutations without manual loading state 🌐 Server Actions — call server functions from client components. No custom API routes. Just 'use server'. 🪜 Server Components — render on server, ship zero JS. Default in Next.js 15. ❤️🔥 useOptimistic — instant UI updates before the server responds. Auto-rollback on failure. ⚙️ use() hook — unwrap promises and read context inside loops, conditions, early returns. 🏠 Native metadata — <title> and <meta> tags from any component. No react-helmet. ❌ No more forwardRef — ref is just a prop in React 19. forwardRef deprecated. 🔍 Better hydration errors — actual diffs instead of "tree will be regenerated". 🤖 React Compiler — automatic memoization at build time. No more useMemo busywork. I wrote the complete guide — every new API with real before/after examples, Server Actions deep dive, and the React 18 → 19 migration steps. Still on React 18? 👇 #React #JavaScript #Frontend #WebDev #ReactJS #100DaysOfBlogging
To view or add a comment, sign in
-
#Day22 Yesterday, my code learned how to talk to my computer. Today, it learned how to flow. Working with streams in Node.js changed how I think about handling data. Before this, reading a file meant loading everything into memory at once. Simple… until the file isn’t small anymore. Then I discovered streams. => ReadStream: Instead of swallowing the whole file, it reads in chunks. Like sipping, not gulping. => WriteStream: Outputs data piece by piece, perfect for logs or large files. => Pipe: This one clicked instantly. Connect a read stream to a write stream, and data just flows automatically. No manual handling, no stress. It feels less like executing code… and more like building a system where data moves. The biggest shift? I’m no longer thinking in terms of “files”, I’m thinking in terms of flow and efficiency. Small change in concept. Massive difference in scalability. Same language. Smarter systems. #NodeJS #JavaScript #BackendDevelopment #LearningToCode #M4ACELearningChallenge
To view or add a comment, sign in
-
-
Node.js developers, ever hit a memory wall when handling large files or processing extensive datasets? If you're buffering entire files into memory before processing them, you might be overlooking one of Node.js's most powerful features: the Stream API. Instead of loading a multi-gigabyte file into RAM (which can quickly exhaust server resources), `fs.createReadStream()` and `fs.createWriteStream()` enable you to process data in small, manageable chunks. This elegant approach allows you to pipe data directly from source to destination, drastically reducing memory footprint and improving application responsiveness. It's a true game-changer for I/O-intensive tasks like real-time log aggregation, video transcoding, or large CSV imports. Building scalable and robust applications relies heavily on efficient resource management, and Streams are a cornerstone of that in Node.js. What are some creative ways you've leveraged Node.js Streams to optimize your applications and avoid memory bottlenecks? Share your insights! #Nodejs #BackendDevelopment #WebDevelopment #PerformanceOptimization #JavaScript #StreamsAPI #DeveloperTips References: Node.js Stream API Documentation - https://lnkd.in/geSRS4_u Working with streams in Node.js: A complete guide - https://lnkd.in/gZjN7eG8
To view or add a comment, sign in
-
Excited to announce Typedrift v1.0.0! 🎉 A new kind of React data-fetching library that eliminates the most painful part of modern full-stack development: “type drift “ between your frontend components and backend queries. What’s New in v1.0.0 - Props = Query: Define your component’s data needs via TypeScript interfaces, everything else is derived automatically. - Zero boilerplate resolvers with ‘view()’, ‘batch.one()’, ‘batch.many()’ - First-class mutations using ‘action()’ with Zod validation, guards, and built-in redirects - Production-ready: middleware, caching, OpenTelemetry, rate limiting, audit logs - Full React 19 + RSC compatibility - No codegen, no separate query hooks, no manual data wiring Why Typedrift? Because the biggest source of bugs in React/Next.js apps isn’t bad code, it’s “out-of-sync types” between what your component expects and what the server actually returns. Typedrift makes the component prop shape the “single source of truth”. The server must conform. Type safety becomes structural. If you’re tired of maintaining query files, fighting stale types, or dealing with the boilerplate of TanStack Query + Zod + manual wiring… this one’s for you. Check it out: https://lnkd.in/e5HRgUgA Would love your feedback, stars, or contributions! #React #TypeScript #NextJS #FullStack #DeveloperTools
To view or add a comment, sign in
-
-
Coming in typedrift v1.1.0 Exactly one week ago, I shipped the first version of Typedrift because I got tired of the same old headaches in data fetching for React-driven frameworks. Data fetching has always felt broken. You define exactly what data a component needs in its props… then duplicate that logic in a separate query. Over time, they drift. You only discover the mismatch at runtime. Typedrift fixes that. Instead of writing queries, you define a typed view from your model. That view becomes the single source of truth for both fetching on the server and the props your component receives. No more duplication. No drift. What’s new in v1.1.0: - TanStack Adapter: seamless integration with TanStack Start - Next.js Adapter: first-class support for App Router and Server Components Clean, type-safe data fetching with zero boilerplate and zero codegen. If you’ve felt the pain of maintaining queries that drift away from your components (especially if you’ve used Relay, tRPC, or TanStack Query), I’d love your feedback. Check it out: - NPM: https://lnkd.in/drSZji_9 - GitHub: https://lnkd.in/e5HRgUgA What do you think — does this approach solve a real problem for you? #React #TypeScript #DataFetching #WebDev #NextJS #TanStack
Excited to announce Typedrift v1.0.0! 🎉 A new kind of React data-fetching library that eliminates the most painful part of modern full-stack development: “type drift “ between your frontend components and backend queries. What’s New in v1.0.0 - Props = Query: Define your component’s data needs via TypeScript interfaces, everything else is derived automatically. - Zero boilerplate resolvers with ‘view()’, ‘batch.one()’, ‘batch.many()’ - First-class mutations using ‘action()’ with Zod validation, guards, and built-in redirects - Production-ready: middleware, caching, OpenTelemetry, rate limiting, audit logs - Full React 19 + RSC compatibility - No codegen, no separate query hooks, no manual data wiring Why Typedrift? Because the biggest source of bugs in React/Next.js apps isn’t bad code, it’s “out-of-sync types” between what your component expects and what the server actually returns. Typedrift makes the component prop shape the “single source of truth”. The server must conform. Type safety becomes structural. If you’re tired of maintaining query files, fighting stale types, or dealing with the boilerplate of TanStack Query + Zod + manual wiring… this one’s for you. Check it out: https://lnkd.in/e5HRgUgA Would love your feedback, stars, or contributions! #React #TypeScript #NextJS #FullStack #DeveloperTools
To view or add a comment, sign in
-
-
My API was fine locally. In production, it started slowing down randomly. No bugs. No crashes. Just slow. . . What was happening: A simple API endpoint was doing this: fetching data looping over it making extra async calls inside the loop Locally: fine. Production: request time kept creeping up under load. The mistake: Not understanding what happens when you mix loops + async calls. People assume this runs “one after another, but async”. It doesn’t. It triggers multiple concurrent operations without control, and suddenly your DB, APIs, or external services are getting hit way harder than expected. Fix (simple version): Instead of uncontrolled async inside loops: limit concurrency (batch or queue) or restructure with proper aggregation or use { Promise.all } only when you actually want parallel load Result: Same logic. Predictable performance. No more “it works on my machine” confidence. Node.js doesn’t usually fail loudly. It just slowly gets tired because you asked it to do everything at once. #NodeJS #BackendDevelopment #WebDevelopment #JavaScript #SystemDesign #SoftwareEngineering #BackendEngineering #PerformanceOptimization #Scalability #TechDebate
To view or add a comment, sign in
-
-
You don’t fix a messy database by just breaking tables. You fix it by understanding why data becomes messy in the first place 👇 Normalisation is a technique. Functional Dependency is the logic behind it. If you skip FD, you’re just guessing your schema. Normalisation ≠ Functional Dependency Normalisation → Organizing tables to reduce redundancy Functional Dependency → Defining how one attribute depends on another When building real systems, you don’t just use Normalisation — you rely on Functional Dependency to handle data consistency and prevent anomalies. Example: UserID → Email If you store Email in multiple places despite this dependency, you’ll face: - update anomalies - deletion issues - inconsistent data ⚠️ Armstrong’s Axioms (Reflexive, Augmentation, Transitivity) are not just theory — they help you reason about how your data should behave. 1NF, 2NF, 3NF, BCNF are results. Functional Dependency is the foundation 🧠 This small distinction changes how you design systems. Building systems > memorizing concepts 🚀 What’s one concept developers often misunderstand? #fullstackdeveloper #softwareengineering #webdevelopment #javascript #reactjs #backend #buildinpublic #nodejs #nextjs #typescript
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development