Performance Optimization Workflow

Full performance review and optimization workflow across database, frontend, and infrastructure layers

The Performance Optimization workflow provides a structured approach to analyzing and improving application performance across all layers of your stack, from database queries to frontend rendering.

Overview#

PropertyValue
Phases4
TierFree
Typical Duration6-10 days
Best ForSlow applications, scaling preparation, user experience improvement

Outcomes#

A successful performance optimization results in:

  • Performance regressions identified and resolved
  • Hotspots addressed across stack layers
  • Baseline metrics captured
  • Improvement report documented

Phases#

Phase 1: Analysis (1-2 days)#

Agents: performance-expert

Establish performance baselines and identify bottlenecks across the application.

Tasks:

  • Measure current performance metrics (Core Web Vitals)
  • Profile server response times
  • Identify slow endpoints and queries
  • Analyze bundle sizes and load times
  • Review caching strategies
  • Document baseline metrics

Key Metrics:

┌─────────────────────────────────────────────────────────┐ │ Core Web Vitals │ ├──────────────────┬──────────────────┬───────────────────┤ │ LCP │ FID │ CLS │ │ Largest │ First Input │ Cumulative │ │ Contentful Paint │ Delay │ Layout Shift │ │ < 2.5s │ < 100ms │ < 0.1 │ └──────────────────┴──────────────────┴───────────────────┘

Analysis Commands:

Loading code block...

Phase 2: Database Optimization (2-3 days)#

Agents: database-expert, performance-expert

Optimize database queries, indexes, and data access patterns.

Tasks:

  • Identify slow queries using EXPLAIN ANALYZE
  • Add missing indexes for common query patterns
  • Optimize N+1 query problems
  • Implement query result caching
  • Review connection pooling configuration
  • Consider read replicas for heavy read workloads

Common Optimizations:

Loading code block...

Prisma Optimizations:

Loading code block...

Phase 3: Frontend Optimization (2-3 days)#

Agents: frontend-expert, performance-expert

Optimize client-side performance, rendering, and asset delivery.

Tasks:

  • Reduce JavaScript bundle size
  • Implement code splitting and lazy loading
  • Optimize images and media assets
  • Improve First Contentful Paint (FCP)
  • Reduce Cumulative Layout Shift (CLS)
  • Implement proper caching headers

Bundle Optimization:

Loading code block...

Image Optimization:

Loading code block...

Font Optimization:

Loading code block...

Phase 4: Infrastructure Optimization (1-2 days)#

Agents: devops-expert

Optimize server configuration, caching, and content delivery.

Tasks:

  • Configure CDN for static assets
  • Implement edge caching strategies
  • Optimize serverless function cold starts
  • Review server-side caching (Redis)
  • Configure proper cache headers
  • Set up performance monitoring

Caching Strategy:

┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ Browser │───▶│ CDN │───▶│ Origin │ │ Cache │ │ Cache │ │ Server │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ ▼ ▼ ▼ Static assets Edge cached Dynamic API max-age=1y stale-while- responses revalidate

Cache Headers Example:

Loading code block...

Starting the Workflow#

Loading code block...

Completion Signals#

Track progress with these checkpoints:

  1. Baseline captured - Initial metrics documented
  2. Improvement report documented - Final metrics and improvements recorded

Performance Budget#

Set targets before optimization:

MetricTargetCritical
LCP< 2.5s< 4.0s
FID< 100ms< 300ms
CLS< 0.1< 0.25
TTI< 3.5s< 7.0s
Bundle Size< 200KB< 500KB
API P95< 200ms< 500ms

Monitoring Setup#

Loading code block...

Tips for Success#

  1. Measure first - Always establish baselines before optimizing
  2. Prioritize by impact - Fix the biggest bottlenecks first
  3. Test in production conditions - Dev performance differs from prod
  4. Monitor continuously - Performance can regress over time
  5. Set budgets - Define acceptable limits for your metrics