惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
T
Tenable Blog
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Security Latest
Security Latest
P
Privacy & Cybersecurity Law Blog
Google Online Security Blog
Google Online Security Blog
SecWiki News
SecWiki News
P
Palo Alto Networks Blog
TaoSecurity Blog
TaoSecurity Blog
Webroot Blog
Webroot Blog
Spread Privacy
Spread Privacy
O
OpenAI News
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
C
Check Point Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
人人都是产品经理
人人都是产品经理
S
Security @ Cisco Blogs
Scott Helme
Scott Helme
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
T
Troy Hunt's Blog
W
WeLiveSecurity
GbyAI
GbyAI
N
News | PayPal Newsroom
Y
Y Combinator Blog
C
Cisco Blogs
H
Help Net Security
The GitHub Blog
The GitHub Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 【当耐特】
Jina AI
Jina AI
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
云风的 BLOG
云风的 BLOG
小众软件
小众软件
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How to optimize application performance — a hands on tutorial
Rizwan Saleem · 2026-05-30 · via DEV Community

Rizwan Saleem

How to optimize application performance — a hands on tutorial

Performance Optimization: Measure Before You Optimize

Donald Knuth's famous warning-"premature optimization is the root of all evil"-boils down to one principle: measure before optimizing. Without real-world evidence that your application is too slow, you're guessing where to fix problems, and guesses create the wrong solutions.

The Golden Rule: Establish a Baseline First

Before touching any code, establish baseline metrics:

  • Load time (FCP, LCP, TTI)
  • Bundle size
  • Query durations
  • Memory usage
  • CPU utilization

Profile the system to locate hot spots, identify root causes, then apply one targeted optimization at a time. After each change, re-measure and document the impact.

Using Profilers to Identify Bottlenecks

How Profilers Work

Performance profilers measure how long routines take to execute, how often they're called, where they're called from, and what percentage of total time is spent there. There are two main types:

Type How It Works Best For Limitation
Instrumenting Inserts timing code at routine start/end Precise timing, call traces Overhead affects short routines
Sampling Interrupts CPU at intervals, records execution point Finding bottlenecks in frequently-called code Approximate timing, no call trace

For accurate analysis, use a combination of profilers.

Popular Profilers by Language

Language Tool Type
Python cProfile + snakeviz Function-level
Python line_profiler Line-level
Python viztracer Timeline
React React DevTools Profiler Component render times
TensorFlow TensorBoard Profiler Host/device breakdown
Browser Chrome DevTools Performance CPU, paint, layout, network

React Profiling Example

The React Profiler reveals:

  • Component render times
  • Re-render counts
  • Commit durations
  • Which interactions cause renders

How to use it:

  1. Open Chrome DevTools → Profiler tab
  2. Click "Record" and interact with your app
  3. Review the flamegraph (visualizes render cost) and ranked view (shows slowest components) ### Common Bottleneck Patterns

1. Unnecessary Re-renders (Frontend)

Components re-render when props change-even if the data is identical. This is the most common React performance issue.

Fix: Use React.memo, useCallback, and useMemo wisely:

// Prevents re-render when props haven't changed
export const UserCard = React.memo(({ name, age }) => (
  <div><h3>{name}</h3><p>{age}</p></div>
));

// Memoizes event handler to prevent child re-renders
const handleClick = useCallback(() => {
  console.log("Clicked");
}, []);

// Memoizes expensive computation
const sortedUsers = useMemo(() => {
  return users.sort((a, b) => a.name.localeCompare(b.name));
}, [users]);

2. N+1 Query Problem (Database)

Fetching related data in loops causes exponential query growth:

// ❌ BAD: N+1 queries
const posts = await db.post.findMany();
const postsWithAuthors = posts.map(post => 
  db.author.findUnique({ where: { id: post.authorId } })
);

// ✅ GOOD: Single batched query
const postsWithAuthors = await db.post.findMany({
  include: { author: true }
});

3. Input-Bound ML Pipelines

In TensorFlow, devices sit idle waiting for data. The Input Pipeline Analyzer identifies this:

  • Red area in step-time graph = device idle time waiting for input
  • Green area = device actually working

Fix: Use tf.data.AUTOTUNE for parallelization and prefetching.

4. Large JavaScript Bundles

Loading the entire app upfront delays Time to Interactive (TTI). Tools like Lighthouse and WebPageTest highlight large bundles.

Optimization Techniques

Caching

Cache results of expensive operations to avoid recomputation:

// Memoize repeated blocks
const expensiveResult = useMemo(() => computeExpensive(data), [data]);

// Cache partials where possible
// Avoid inline DB calls in templates

Use long-term caching for static chunks-this reduces load on repeat visits.

Lazy Loading

Delay loading code until the user actually needs it:

// React lazyloading with Suspense
const SettingsPanel = React.lazy(() => import("./SettingsPanel"));

export function App() {
  return (
    <Suspense fallback={<div>Loading…</div>}>
      <SettingsPanel />
    </Suspense>
  );
}

Benefits:

  • Reduced initial bundle size
  • Faster TTI
  • Load components only when needed

Lazy loading is recommended even with browser caching because it improves initial load time and resource efficiency.

Bundle Optimization

Technique When to Use
Route-based splitting SPAs-each page loads only what's necessary
Code splitting Split early, review often as project grows
Preloading Assets needed immediately
Prefetching Assets needed soon (next page)
Keep chunks small Avoid excessive network requests

Prefer route-based splitting for Single Page Applications-this ensures each page loads only what's necessary.

Database Query Optimization

  • Use batched or parameterized queries in middleware/API routes, not templates
  • Add indexes on frequently queried columns
  • Use EXPLAIN to analyze query plans
  • Avoid SELECT *-fetch only needed columns
  • Implement query result caching for read-heavy workloads

Frontend Rendering Optimization

Strategy Impact
Virtualization (react-window) Huge gains for long lists
Stable keys (use ID, not index) Prevents unnecessary re-renders
Shallow component trees Reduces render propagation
Debouncing/throttling Prevents excessive event handling
SSR/Streaming (Next.js, Remix) Faster FCP, better SEO

Use virtualization for huge lists-render only what's visible in the viewport.

// Virtualized list example
import { FixedSizeList } from 'react-window';

<FixedSizeList
  height={600}
  itemCount={10000}
  itemSize={35}
  width="100%"
>
  {({ index, style }) => <ListItem index={index} style={style} />}
</FixedSizeList>

Real-World Examples

FinTech Platform Optimization (DATAFOREST Case Study)

A financial services company faced performance degradation with processes stuck in queues. The team:

  1. Performed technical audit of AWS infrastructure
  2. Created bottleneck monitoring system
  3. Re-developed inefficient SQL queries and data pipelines
  4. Implemented horizontal scaling with Docker/Kubernetes

Result: Increased application performance, stability, and resilience while reducing operational costs.

Agricultural Tech Dashboard (30 MHz Case Study)

Over 4 months with 13 interventions:

  • 98.37% reduction in First Contentful Paint (desktop)
  • 97.56% reduction on mobile
  • 48.25% improvement in Speed Index (desktop)

Interventions included code splitting, caching, image optimization, and database query improvements.

React App Optimization

One developer profiled a React app and found:

  • Excessive re-renders in a user list component
  • Large bundle due to unused lodash functions
  • N+1 queries when fetching posts with authors

Fixes applied:

  • Added React.memo to list items
  • Replaced lodash with native Array.prototype methods (reduced bundle by 68KB)
  • Converted to batched queries

Result: TTI improved from 4.2s to 1.8s.

When to Stop Optimizing

Optimization has diminishing returns. Stop when:

  1. Metrics meet user expectations: Core Web Vitals are in the "good" range (LCP < 2.5s, FID < 100ms, CLS < 0.1)
  2. ROI drops: The next optimization takes 10 hours for a 2% improvement
  3. Readability suffers: Code becomes unmaintainable
  4. You've hit the bottleneck ceiling: The limiting factor is now network latency or third-party services, not your code

Key principle: Prefer high-impact fixes (code-splitting, caching, indexing) over micro-optimizations.

Make one change at a time and measure its isolated effect-this tells you what actually worked.

Optimization Workflow Checklist

  1. Measure baseline (load time, bundle size, query duration)
  2. Profile to find real bottleneck (not where you guess it is)
  3. Identify root cause (input-bound, re-renders, N+1 queries)
  4. Apply one targeted fix
  5. Re-measure and document impact
  6. Verify tests pass and functionality intact
  7. Integrate monitoring into CI/CD (Lighthouse CI, bundle size tracking)

Performance optimization isn't about isolated tweaks-it's a continuous, iterative process.

Key Takeaways

Principle Why It Matters
Measure before optimizing Guessing creates wrong fixes
Profile to find real bottleneck 80% of time spent in 20% of code
One change at a time Isolates what actually worked
High-impact > micro-optimizations Code-splitting beats loop unrolling
Monitor continuously Performance degrades over time

Mastering these techniques is one of the most impactful skills you can develop as an engineer.


Rizwan Saleem — https://rizwansaleem.co