AI Prompt for Bug Fixing
Optimize real-time WebSocket connections performance in Scala with profiling, benchmarking, and targeted improvements.
You are an expert performance engineer with deep expertise in system optimization. Optimize the performance of real-time WebSocket connections in a Scala application. **Focus area:** real-time WebSocket connections **Language:** Scala **Performance goal:** reduce latency by 50% **Current pain point:** The real-time WebSocket connections is too slow and needs optimization ## Performance Assessment Framework ### Step 1: Measure Current Performance - Key metrics to capture for real-time WebSocket connections (latency, throughput, memory, CPU) - Profiling tools specific to Scala and how to use them - How to set up reproducible benchmarks - Baseline measurement methodology (percentiles: p50, p95, p99) ### Step 2: Identify Bottlenecks - Common performance bottlenecks in Scala real-time WebSocket connections - How to read and interpret profiler output - Flame graph analysis for CPU-bound issues - Memory allocation analysis for memory-bound issues - I/O analysis for network or disk-bound issues ### Step 3: Optimize (Ordered by Impact) Provide 10 optimization techniques for real-time WebSocket connections in Scala, ordered from highest to lowest impact: For each technique: 1. What it optimizes and expected improvement range 2. Implementation approach (describe the code changes needed) 3. Trade-offs (complexity, readability, maintainability) 4. When NOT to use this optimization 5. How to measure the improvement ### Step 4: Validate Improvements - A/B testing approach for performance changes - Load testing methodology and tool recommendations - Regression testing to ensure functionality is preserved - Production monitoring to verify improvements under real load ## Scala-Specific Performance Tips - Runtime-specific optimizations (JIT, GC tuning, memory model) - Library and framework-specific performance tricks - Build-time optimizations (tree shaking, minification, AOT compilation) - Caching strategies at every layer ## Performance Budget - Define performance budgets for real-time WebSocket connections - Set up automated performance regression detection - Create a performance dashboard with key metrics - Establish a review process for performance-impacting changes - Use precise technical terminology appropriate for the audience - Include code examples, configurations, or specifications where relevant - Document assumptions, prerequisites, and dependencies - Provide error handling and edge case considerations Present as numbered steps. Each step should have: a clear action title, detailed instructions, expected outcome, and common pitfalls to avoid.
More prompts for Bug Fixing.
Diagnose and resolve dependency conflicts, version mismatches, and peer dependency issues in any package manager.
Analyze concurrent code for race conditions, deadlocks, and timing bugs with detection strategies and fixes.
Analyze code for memory leak patterns, identify allocation issues, and generate detection and fix strategies.
Guide a structured incident response with root cause analysis, mitigation steps, and post-mortem documentation.
Comprehensive code review guide focused on error handling for Go projects.
Comprehensive code review guide focused on async patterns for Java projects.