chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,415 @@
|
||||
# System Behavior Simulator
|
||||
|
||||
Simulate system performance under various loads with capacity planning, bottleneck identification, and optimization strategies.
|
||||
|
||||
## Instructions
|
||||
|
||||
You are tasked with creating comprehensive system behavior simulations to predict performance, identify bottlenecks, and optimize capacity planning. Follow this approach: **$ARGUMENTS**
|
||||
|
||||
### 1. Prerequisites Assessment
|
||||
|
||||
**Critical System Context Validation:**
|
||||
|
||||
- **System Architecture**: What type of system are you simulating behavior for?
|
||||
- **Performance Goals**: What are the target performance metrics and SLAs?
|
||||
- **Load Characteristics**: What are the expected usage patterns and traffic profiles?
|
||||
- **Resource Constraints**: What infrastructure and budget limitations apply?
|
||||
- **Optimization Objectives**: What aspects of performance are most critical to optimize?
|
||||
|
||||
**If context is unclear, guide systematically:**
|
||||
|
||||
```
|
||||
Missing System Architecture:
|
||||
"What type of system needs behavior simulation?
|
||||
- Web Application: User-facing application with HTTP traffic patterns
|
||||
- API Service: Backend service with programmatic access patterns
|
||||
- Data Processing: Batch or stream processing with throughput requirements
|
||||
- Database System: Data storage and query processing optimization
|
||||
- Microservices: Distributed system with inter-service communication
|
||||
|
||||
Please specify system components, technology stack, and deployment architecture."
|
||||
|
||||
Missing Performance Goals:
|
||||
"What performance objectives need to be met?
|
||||
- Response Time: Target latency for user requests (p50, p95, p99)
|
||||
- Throughput: Requests per second or transactions per minute
|
||||
- Availability: Uptime targets and fault tolerance requirements
|
||||
- Scalability: User growth and load handling capabilities
|
||||
- Resource Efficiency: CPU, memory, storage, and network optimization"
|
||||
```
|
||||
|
||||
### 2. System Architecture Modeling
|
||||
|
||||
**Systematically map system components and interactions:**
|
||||
|
||||
#### Component Architecture Framework
|
||||
```
|
||||
System Component Mapping:
|
||||
|
||||
Application Layer:
|
||||
- Frontend Components: User interfaces, single-page applications, mobile apps
|
||||
- Application Services: Business logic, workflow processing, API endpoints
|
||||
- Background Services: Scheduled jobs, message processing, batch operations
|
||||
- Integration Services: External API calls, webhook handling, data synchronization
|
||||
|
||||
Data Layer:
|
||||
- Primary Databases: Transactional data storage and query processing
|
||||
- Cache Systems: Redis, Memcached, CDN, and application-level caching
|
||||
- Message Queues: Asynchronous communication and event processing
|
||||
- Search Systems: Elasticsearch, Solr, or database search capabilities
|
||||
|
||||
Infrastructure Layer:
|
||||
- Load Balancers: Traffic distribution and health checking
|
||||
- Web Servers: HTTP request handling and static content serving
|
||||
- Application Servers: Dynamic content generation and business logic
|
||||
- Network Components: Firewalls, VPNs, and traffic routing
|
||||
```
|
||||
|
||||
#### Interaction Pattern Modeling
|
||||
```
|
||||
System Interaction Analysis:
|
||||
|
||||
Synchronous Interactions:
|
||||
- Request-Response: Direct API calls and database queries
|
||||
- Service Mesh: Inter-service communication with service discovery
|
||||
- Database Transactions: ACID compliance and locking mechanisms
|
||||
- External API Calls: Third-party service dependencies and timeouts
|
||||
|
||||
Asynchronous Interactions:
|
||||
- Message Queues: Pub/sub patterns and event-driven processing
|
||||
- Event Streams: Real-time data processing and analytics
|
||||
- Background Jobs: Scheduled tasks and delayed processing
|
||||
- Webhooks: External system notifications and callbacks
|
||||
|
||||
Data Flow Patterns:
|
||||
- Read Patterns: Query optimization and caching strategies
|
||||
- Write Patterns: Data ingestion and consistency management
|
||||
- Batch Processing: ETL operations and data pipeline processing
|
||||
- Real-time Processing: Stream processing and live analytics
|
||||
```
|
||||
|
||||
### 3. Load Modeling Framework
|
||||
|
||||
**Create realistic traffic and usage pattern simulations:**
|
||||
|
||||
#### Traffic Pattern Analysis
|
||||
```
|
||||
Load Characteristics Modeling:
|
||||
|
||||
User Behavior Patterns:
|
||||
- Daily Patterns: Peak hours, lunch dips, overnight minimums
|
||||
- Weekly Patterns: Weekday vs weekend usage variations
|
||||
- Seasonal Patterns: Holiday traffic, business cycle fluctuations
|
||||
- Event-Driven Spikes: Marketing campaigns, viral content, news events
|
||||
|
||||
Request Distribution:
|
||||
- Geographic Distribution: Multi-region traffic and latency patterns
|
||||
- Device Distribution: Mobile vs desktop vs API usage patterns
|
||||
- Feature Distribution: Popular vs niche feature usage ratios
|
||||
- User Type Distribution: New vs returning vs power user behaviors
|
||||
|
||||
Load Volume Scaling:
|
||||
- Concurrent Users: Simultaneous active sessions and request patterns
|
||||
- Request Rate: Transactions per second with burst capabilities
|
||||
- Data Volume: Payload sizes and data transfer requirements
|
||||
- Connection Patterns: Session duration and connection pooling
|
||||
```
|
||||
|
||||
#### Synthetic Load Generation
|
||||
```
|
||||
Load Testing Scenario Framework:
|
||||
|
||||
Baseline Load Testing:
|
||||
- Normal Traffic: Typical daily usage patterns and request volumes
|
||||
- Sustained Load: Constant traffic over extended periods
|
||||
- Gradual Ramp: Slow traffic increase to identify scaling points
|
||||
- Steady State: Stable load for performance baseline establishment
|
||||
|
||||
Stress Testing:
|
||||
- Peak Load: Maximum expected traffic during busy periods
|
||||
- Capacity Testing: System limits and breaking point identification
|
||||
- Spike Testing: Sudden traffic increases and recovery behavior
|
||||
- Volume Testing: Large data sets and high-throughput scenarios
|
||||
|
||||
Resilience Testing:
|
||||
- Failure Scenarios: Component outages and degraded service behavior
|
||||
- Recovery Testing: System restoration and performance recovery
|
||||
- Chaos Engineering: Random failure injection and system adaptation
|
||||
- Disaster Simulation: Major outage scenarios and business continuity
|
||||
```
|
||||
|
||||
### 4. Performance Modeling Engine
|
||||
|
||||
**Create comprehensive system performance predictions:**
|
||||
|
||||
#### Performance Metric Framework
|
||||
```
|
||||
Multi-Dimensional Performance Analysis:
|
||||
|
||||
Response Time Metrics:
|
||||
- Request Latency: End-to-end response time measurement
|
||||
- Processing Time: Application logic execution duration
|
||||
- Database Query Time: Data access and retrieval performance
|
||||
- Network Latency: Communication overhead and bandwidth utilization
|
||||
|
||||
Throughput Metrics:
|
||||
- Requests per Second: HTTP request handling capacity
|
||||
- Transactions per Minute: Business operation completion rate
|
||||
- Data Processing Rate: Batch job and stream processing throughput
|
||||
- Concurrent User Capacity: Simultaneous session handling capability
|
||||
|
||||
Resource Utilization Metrics:
|
||||
- CPU Usage: Processing power consumption and efficiency
|
||||
- Memory Usage: RAM allocation and garbage collection impact
|
||||
- Storage I/O: Disk read/write performance and capacity
|
||||
- Network Bandwidth: Data transfer rates and congestion management
|
||||
|
||||
Quality Metrics:
|
||||
- Error Rates: Failed requests and transaction failures
|
||||
- Availability: System uptime and service reliability
|
||||
- Consistency: Data integrity and transaction isolation
|
||||
- Security: Authentication, authorization, and data protection overhead
|
||||
```
|
||||
|
||||
#### Performance Prediction Modeling
|
||||
```
|
||||
Predictive Performance Framework:
|
||||
|
||||
Analytical Models:
|
||||
- Queueing Theory: Wait time and service rate mathematical modeling
|
||||
- Little's Law: Relationship between concurrency, throughput, and latency
|
||||
- Capacity Planning: Resource requirement forecasting and optimization
|
||||
- Bottleneck Analysis: System constraint identification and resolution
|
||||
|
||||
Simulation Models:
|
||||
- Discrete Event Simulation: System behavior modeling with event queues
|
||||
- Monte Carlo Simulation: Probabilistic performance outcome analysis
|
||||
- Load Testing Data: Historical performance pattern extrapolation
|
||||
- Machine Learning: Pattern recognition and predictive analytics
|
||||
|
||||
Hybrid Models:
|
||||
- Analytical + Empirical: Mathematical models calibrated with real data
|
||||
- Multi-Layer Modeling: Component-level models aggregated to system level
|
||||
- Dynamic Adaptation: Models that adjust based on real-time performance
|
||||
- Scenario-Based: Different models for different load and usage patterns
|
||||
```
|
||||
|
||||
### 5. Bottleneck Identification System
|
||||
|
||||
**Systematically identify and analyze performance constraints:**
|
||||
|
||||
#### Bottleneck Detection Framework
|
||||
```
|
||||
Performance Constraint Analysis:
|
||||
|
||||
CPU Bottlenecks:
|
||||
- High CPU Utilization: Processing-intensive operations and algorithms
|
||||
- Thread Contention: Locking and synchronization overhead
|
||||
- Context Switching: Excessive thread creation and management
|
||||
- Inefficient Algorithms: Poor time complexity and optimization opportunities
|
||||
|
||||
Memory Bottlenecks:
|
||||
- Memory Leaks: Gradual memory consumption and garbage collection pressure
|
||||
- Large Object Allocation: Memory-intensive operations and caching strategies
|
||||
- Memory Fragmentation: Allocation patterns and memory pool management
|
||||
- Cache Misses: Application and database cache effectiveness
|
||||
|
||||
I/O Bottlenecks:
|
||||
- Database Performance: Query optimization and index effectiveness
|
||||
- Disk I/O: Storage access patterns and disk performance limits
|
||||
- Network I/O: Bandwidth limitations and latency optimization
|
||||
- External Dependencies: Third-party service response times and reliability
|
||||
|
||||
Application Bottlenecks:
|
||||
- Blocking Operations: Synchronous calls and thread pool exhaustion
|
||||
- Inefficient Code: Poor algorithms and unnecessary processing
|
||||
- Resource Contention: Shared resource access and locking mechanisms
|
||||
- Configuration Issues: Suboptimal settings and parameter tuning
|
||||
```
|
||||
|
||||
#### Root Cause Analysis
|
||||
- Performance profiling and trace analysis
|
||||
- Correlation analysis between metrics and bottlenecks
|
||||
- Historical pattern recognition and trend analysis
|
||||
- Comparative analysis across different system configurations
|
||||
|
||||
### 6. Optimization Strategy Generation
|
||||
|
||||
**Create systematic performance improvement approaches:**
|
||||
|
||||
#### Performance Optimization Framework
|
||||
```
|
||||
Multi-Level Optimization Strategies:
|
||||
|
||||
Code-Level Optimizations:
|
||||
- Algorithm Optimization: Improved time and space complexity
|
||||
- Database Query Optimization: Index usage and query plan improvement
|
||||
- Caching Strategies: Application, database, and CDN caching
|
||||
- Asynchronous Processing: Non-blocking operations and parallelization
|
||||
|
||||
Architecture-Level Optimizations:
|
||||
- Horizontal Scaling: Load distribution across multiple instances
|
||||
- Vertical Scaling: Resource allocation and capacity increases
|
||||
- Caching Layers: Multi-tier caching and cache invalidation strategies
|
||||
- Database Sharding: Data partitioning and distributed storage
|
||||
|
||||
Infrastructure-Level Optimizations:
|
||||
- Auto-Scaling: Dynamic resource allocation based on demand
|
||||
- Load Balancing: Traffic distribution and health checking optimization
|
||||
- CDN Implementation: Geographic content distribution and edge caching
|
||||
- Network Optimization: Bandwidth allocation and latency reduction
|
||||
|
||||
System-Level Optimizations:
|
||||
- Monitoring and Alerting: Performance visibility and proactive issue detection
|
||||
- Capacity Planning: Resource forecasting and growth accommodation
|
||||
- Disaster Recovery: Backup strategies and failover mechanisms
|
||||
- Security Optimization: Performance-aware security implementation
|
||||
```
|
||||
|
||||
#### Cost-Benefit Analysis
|
||||
- Performance improvement quantification and measurement
|
||||
- Infrastructure cost implications and budget optimization
|
||||
- Development effort estimation and resource allocation
|
||||
- ROI calculation for different optimization strategies
|
||||
|
||||
### 7. Capacity Planning Integration
|
||||
|
||||
**Connect performance insights to infrastructure and resource planning:**
|
||||
|
||||
#### Capacity Planning Framework
|
||||
```
|
||||
Systematic Capacity Management:
|
||||
|
||||
Growth Projection:
|
||||
- User Growth: Customer acquisition and usage pattern evolution
|
||||
- Data Growth: Storage requirements and processing volume increases
|
||||
- Feature Growth: New capabilities and functionality impacts
|
||||
- Geographic Growth: Multi-region expansion and latency requirements
|
||||
|
||||
Resource Forecasting:
|
||||
- Compute Resources: CPU, memory, and processing power requirements
|
||||
- Storage Resources: Database, file system, and backup capacity needs
|
||||
- Network Resources: Bandwidth, connectivity, and latency optimization
|
||||
- Human Resources: Team scaling and expertise development needs
|
||||
|
||||
Scaling Strategy:
|
||||
- Horizontal Scaling: Instance multiplication and load distribution
|
||||
- Vertical Scaling: Resource enhancement and capacity increases
|
||||
- Auto-Scaling: Dynamic adjustment based on real-time demand
|
||||
- Manual Scaling: Planned capacity increases and maintenance windows
|
||||
|
||||
Cost Optimization:
|
||||
- Reserved Capacity: Long-term resource commitment and cost savings
|
||||
- Spot Instances: Variable pricing and cost-effective temporary capacity
|
||||
- Right-Sizing: Optimal resource allocation and waste elimination
|
||||
- Multi-Cloud: Provider comparison and cost arbitrage opportunities
|
||||
```
|
||||
|
||||
### 8. Output Generation and Recommendations
|
||||
|
||||
**Present simulation insights in actionable performance optimization format:**
|
||||
|
||||
```
|
||||
## System Behavior Simulation: [System Name]
|
||||
|
||||
### Performance Summary
|
||||
- Current Capacity: [baseline performance metrics]
|
||||
- Bottleneck Analysis: [primary performance constraints identified]
|
||||
- Optimization Potential: [improvement opportunities and expected gains]
|
||||
- Scaling Requirements: [resource needs for growth accommodation]
|
||||
|
||||
### Load Testing Results
|
||||
|
||||
| Scenario | Throughput | Latency (p95) | Error Rate | Resource Usage |
|
||||
|----------|------------|---------------|------------|----------------|
|
||||
| Normal Load | 500 RPS | 200ms | 0.1% | 60% CPU |
|
||||
| Peak Load | 1000 RPS | 800ms | 2.5% | 85% CPU |
|
||||
| Stress Test | 1500 RPS | 2000ms | 15% | 95% CPU |
|
||||
|
||||
### Bottleneck Analysis
|
||||
- Primary Bottleneck: [most limiting performance factor]
|
||||
- Secondary Bottlenecks: [additional constraints affecting performance]
|
||||
- Cascade Effects: [how bottlenecks impact other system components]
|
||||
- Resolution Priority: [recommended order of bottleneck addressing]
|
||||
|
||||
### Optimization Recommendations
|
||||
|
||||
#### Immediate Optimizations (0-30 days):
|
||||
- Quick Wins: [low-effort, high-impact improvements]
|
||||
- Configuration Tuning: [parameter adjustments and settings optimization]
|
||||
- Query Optimization: [database and application query improvements]
|
||||
- Caching Implementation: [strategic caching layer additions]
|
||||
|
||||
#### Medium-term Optimizations (1-6 months):
|
||||
- Architecture Changes: [structural improvements and scaling strategies]
|
||||
- Infrastructure Upgrades: [hardware and platform enhancements]
|
||||
- Code Refactoring: [application optimization and efficiency improvements]
|
||||
- Monitoring Enhancement: [observability and alerting system improvements]
|
||||
|
||||
#### Long-term Optimizations (6+ months):
|
||||
- Technology Migration: [platform or framework modernization]
|
||||
- System Redesign: [fundamental architecture improvements]
|
||||
- Capacity Expansion: [infrastructure scaling and geographic distribution]
|
||||
- Innovation Integration: [new technology adoption and competitive advantage]
|
||||
|
||||
### Capacity Planning
|
||||
- Current Capacity: [existing system limits and headroom]
|
||||
- Growth Accommodation: [resource scaling for projected demand]
|
||||
- Cost Implications: [budget requirements for capacity increases]
|
||||
- Timeline Requirements: [implementation schedule for capacity improvements]
|
||||
|
||||
### Monitoring and Alerting Strategy
|
||||
- Key Performance Indicators: [critical metrics for ongoing monitoring]
|
||||
- Alert Thresholds: [performance degradation warning levels]
|
||||
- Escalation Procedures: [response protocols for performance issues]
|
||||
- Regular Review Schedule: [ongoing optimization and capacity assessment]
|
||||
```
|
||||
|
||||
### 9. Continuous Performance Learning
|
||||
|
||||
**Establish ongoing simulation refinement and system optimization:**
|
||||
|
||||
#### Performance Validation
|
||||
- Real-world performance comparison to simulation predictions
|
||||
- Optimization effectiveness measurement and validation
|
||||
- User experience correlation with system performance metrics
|
||||
- Business impact assessment of performance improvements
|
||||
|
||||
#### Model Enhancement
|
||||
- Simulation accuracy improvement based on actual system behavior
|
||||
- Load pattern refinement and user behavior modeling
|
||||
- Bottleneck prediction enhancement and early warning systems
|
||||
- Optimization strategy effectiveness tracking and improvement
|
||||
|
||||
## Usage Examples
|
||||
|
||||
```bash
|
||||
# Web application performance simulation
|
||||
/performance:system-behavior-simulator Simulate e-commerce platform performance under Black Friday traffic with 10x normal load
|
||||
|
||||
# API service scaling analysis
|
||||
/performance:system-behavior-simulator Model REST API performance for mobile app with 1M+ daily active users and geographic distribution
|
||||
|
||||
# Database performance optimization
|
||||
/performance:system-behavior-simulator Simulate database performance for analytics workload with real-time reporting requirements
|
||||
|
||||
# Microservices capacity planning
|
||||
/performance:system-behavior-simulator Model microservices mesh performance under various failure scenarios and auto-scaling conditions
|
||||
```
|
||||
|
||||
## Quality Indicators
|
||||
|
||||
- **Green**: Comprehensive load modeling, validated bottleneck analysis, quantified optimization strategies
|
||||
- **Yellow**: Good load coverage, basic bottleneck identification, estimated optimization benefits
|
||||
- **Red**: Limited load scenarios, unvalidated bottlenecks, qualitative-only optimization suggestions
|
||||
|
||||
## Common Pitfalls to Avoid
|
||||
|
||||
- Load unrealism: Testing with artificial patterns that don't match real usage
|
||||
- Bottleneck tunnel vision: Focusing on single constraints while ignoring others
|
||||
- Optimization premature: Optimizing for problems that don't exist yet
|
||||
- Capacity under-planning: Not accounting for growth and traffic spikes
|
||||
- Monitoring blindness: Not establishing ongoing performance visibility
|
||||
- Cost ignorance: Optimizing performance without considering budget constraints
|
||||
|
||||
Transform system performance from reactive firefighting into proactive, data-driven optimization through comprehensive behavior simulation and capacity planning.
|
||||
Reference in New Issue
Block a user