计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
appfolio-cost-tuning【效率与协作】Optimize AppFolio API costs through efficient usage patterns. Trigger: "appfolio cost".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: appfolio-cost-tuning description: 'Optimize AppFolio API costs through efficient usage patterns.
Trigger: "appfolio cost".
' allowed-tools: Read, Write, Edit, Bash(npm:), Bash(curl:), Grep version: 1.5.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io tags:
AppFolio Stack API pricing is partner-agreement based, with costs scaling by API call volume per managed property. Property management portfolios generate high-frequency reads for tenant lookups, lease status checks, and maintenance requests. Each redundant API call erodes margin on per-unit revenue. Optimizing call patterns directly impacts operational profitability, especially for portfolios managing hundreds or thousands of units where even small per-call costs compound rapidly.
| Component | Cost Driver | Optimization |
|---|---|---|
| Property/unit reads | Per-call pricing on tenant and unit endpoints | Cache with 10-15 min TTL; property data changes infrequently |
| Lease operations | Bulk lease queries across entire portfolio | Fetch all leases once, filter locally instead of per-unit calls |
| Maintenance requests | Polling for new work orders | Use verified provider events, or bounded incremental polling |
| Reporting exports | Large payload downloads for financial reports | Schedule off-peak, cache results for 24h |
| Vendor/owner lookups | Repeated lookups for the same contacts | Build a local lookup table, refresh daily |
class AppFolioCache {
private cache = new Map<string, { data: unknown; expiry: number }>();
private readonly maxEntries = 1_000;
get(key: string): any | null {
const entry = this.cache.get(key);
if (!entry || Date.now() > entry.expiry) return null;
return entry.data;
}
set(key: string, data: unknown, ttlMs = 600_000): void {
if (this.cache.size >= this.maxEntries && !this.cache.has(key)) {
this.cache.delete(this.cache.keys().next().value!);
}
this.cache.set(key, { data, expiry: Date.now() + ttlMs });
}
async fetchWithCache(endpoint: string, ttlMs?: number): Promise<any> {
const cached = this.get(endpoint);
if (cached) return cached;
const response = await fetch(endpoint);
const data = await response.json();
this.set(endpoint, data, ttlMs);
return data;
}
}
class AppFolioUsageMonitor {
private calls: Array<{ endpoint: string; timestamp: number }> = [];
private budgetLimit = 10_000; // daily call budget
record(endpoint: string): void {
this.calls.push({ endpoint, timestamp: Date.now() });
const todayCalls = this.getTodayCount();
if (todayCalls > this.budgetLimit * 0.8) {
console.warn(`AppFolio API budget 80% consumed: ${todayCalls}/${this.budgetLimit}`);
}
}
getTodayCount(): number {
const startOfDay = new Date().setHours(0, 0, 0, 0);
return this.calls.filter(c => c.timestamp > startOfDay).length;
}
}
modified_since parameter| Issue | Cause | Fix |
|---|---|---|
| 429 Too Many Requests | Exceeded rate limit | Implement exponential backoff with jitter |
| Stale cache serving old data | TTL too long for volatile data | Reduce TTL for maintenance/lease endpoints to 2-5 min |
| Budget alerts firing daily | Polling loop running on short interval | Switch to webhook-driven architecture |
| Duplicate API calls | Multiple services fetching same data | Centralize through shared cache layer |
| Large payload timeouts | Fetching full portfolio in single call | Paginate requests, process in batches of 100 |
For a nightly property-status sync, capture a baseline call count and response size, cache only the property ID and permitted occupancy summary, and cap the cache at the approved entry count. Enable an incremental cursor only after a staging replay proves no records are lost; otherwise retain low-frequency, rate-limited polling. When the budget alert fires, stop non-critical refreshes and surface the age of the last verified result. Do not use cached or partial data to make a lease, payment, or safety decision without operator review.
See appfolio-performance-tuning.