| name | performance |
| description | Optimize application performance through caching strategies, load balancing, database scaling, and monitoring. Build systems handling thousands of concurrent users. |
| sasmp_version | 2.0.0 |
| bonded_agent | 05-caching-performance |
| bond_type | PRIMARY_BOND |
| atomic_operations | ["BOTTLENECK_ANALYSIS","CACHE_IMPLEMENTATION","LOAD_BALANCING_CONFIG","SCALING_STRATEGY"] |
| parameter_validation | {"query":{"type":"string","required":true,"minLength":5,"maxLength":2000},"current_rps":{"type":"integer","required":false,"description":"Current requests per second"},"target_latency_ms":{"type":"integer","required":false,"description":"Target P99 latency in milliseconds"}} |
| retry_logic | {"max_attempts":3,"backoff":"exponential","initial_delay_ms":1000} |
| logging_hooks | {"on_invoke":"skill.performance.invoked","on_success":"skill.performance.completed","on_error":"skill.performance.failed"} |
| exit_codes | {"SUCCESS":0,"INVALID_INPUT":1,"METRICS_UNAVAILABLE":2,"OPTIMIZATION_FAILED":3} |
Performance Optimization Skill
Bonded to: caching-performance-agent
Quick Start
"My API is slow, help me optimize it"
"Set up Redis caching for my application"
"Configure load balancing for high availability"
Instructions
- Identify Bottlenecks: Profile application, analyze metrics
- Choose Strategy: Select caching, scaling, or optimization approach
- Implement Cache: Set up Redis/Memcached with appropriate pattern
- Configure Scaling: Horizontal or vertical based on needs
- Monitor Results: Set up APM and track improvements
Caching Patterns
| Pattern | Use Case | Consistency | Complexity |
|---|
| Cache-Aside | Read-heavy, tolerates stale | Eventual | Low |
| Write-Through | Write-heavy, needs consistency | Strong | Medium |
| Write-Behind | High throughput writes | Eventual | High |
| Refresh-Ahead | Predictable access | Strong | Medium |
Decision Tree
Performance Issue?
│
├─→ High latency → Check database queries
│ ├─→ Slow queries → Add indexes, optimize SQL
│ └─→ Network → Add caching, reduce round-trips
│
├─→ High CPU → Profile code
│ ├─→ Algorithmic → Optimize algorithms
│ └─→ Too much load → Scale horizontally
│
└─→ Memory issues → Analyze memory usage
├─→ Leaks → Find and fix leaks
└─→ Large data → Implement pagination, streaming
Examples
Example 1: Redis Cache-Aside
import redis
import json
from functools import wraps
r = redis.Redis(host='localhost', port=6379, decode_responses=)
():
():
():
cache_key =
cached = r.get(cache_key)
cached:
json.loads(cached)
result = func(*args, **kwargs)
r.setex(cache_key, ttl_seconds, json.dumps(result))
result
wrapper
decorator
() -> :
{: user_id, : }