Skip to main content
maintainx-performance-tuning Optimize MaintainX API integration performance.
Use when experiencing slow API responses, optimizing data fetching,
or improving integration throughput with MaintainX.
Trigger with phrases like "maintainx performance", "maintainx slow",
"optimize maintainx", "maintainx caching", "maintainx faster".
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill maintainx-performance-tuning명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... jeremylongshore
jeremylongshore/claude-code-plugins-plus-skills
GitHub 저장소 열기 name maintainx-performance-tuning description Optimize MaintainX API integration performance.
Use when experiencing slow API responses, optimizing data fetching,
or improving integration throughput with MaintainX.
Trigger with phrases like "maintainx performance", "maintainx slow",
"optimize maintainx", "maintainx caching", "maintainx faster".
allowed-tools Read, Write, Edit, Bash(npm:*) version 1.11.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","maintainx","api","performance"] compatibility Designed for Claude Code, also compatible with Codex and OpenClaw
MaintainX Performance Tuning
Overview
Optimize MaintainX integration performance with caching, connection pooling, efficient pagination, and request deduplication.
Prerequisites
MaintainX integration working
Node.js 18+
Redis (recommended for production caching)
Performance baseline measurements
Instructions
Step 1: Connection Pooling with Keep-Alive
import axios from 'axios' ;
import http from 'node:http' ;
import https from 'node:https' ;
const httpAgent = new http.Agent ({ keepAlive : true , maxSockets : 10 });
const httpsAgent = new https.Agent ({ keepAlive : true , maxSockets : 10 });
const client = axios.create ({
baseURL : 'https://api.getmaintainx.com/v1' ,
headers : {
Authorization : `Bearer ${process.env.MAINTAINX_API_KEY} ` ,
'Content-Type' : 'application/json' ,
},
httpAgent,
httpsAgent,
timeout : 30_000 ,
});
Step 2: Multi-Level Caching
interface CacheLayer <T> {
get (key : string ): Promise <T | undefined >;
set (key : string , value : T, ttlMs : number ): Promise <void >;
}
class MemoryCache <T> implements CacheLayer <T> {
private store = new Map <string , { value : T; expiresAt : number }>();
async get (key : string ) {
const entry = this .store .get (key);
if (entry && entry.expiresAt > Date .now ()) return entry.value ;
this .store .delete (key);
return undefined ;
}
async set (key : string , value : T, ttlMs : number ) {
this .store .set (key, { value, expiresAt : Date .now () + ttlMs });
}
}
class RedisCache <T> implements CacheLayer <T> {
constructor (private redis : any ) {}
async get (key : string ) {
const data = await this .redis .get (`mx:${key} ` );
return data ? JSON .parse (data) : undefined ;
}
async set (key : string , value : T, ttlMs : number ) {
await this .redis .setex (`mx:${key} ` , Math .ceil (ttlMs / 1000 ), JSON .stringify (value));
}
}
class MultiCache <T> {
constructor (private l1 : CacheLayer <T>, private l2 : CacheLayer <T> ) {}
async getOrFetch (key : string , ttlMs : number , fetcher : () => Promise <T>): Promise <T> {
let value = await this .l1 .get (key);
if (value !== undefined ) return value;
value = await this .l2 .get (key);
if (value !== undefined ) {
await this .l1 .set (key, value, ttlMs / 2 );
return value;
}
value = await fetcher ();
await this .l1 .set (key, value, ttlMs / 2 );
await this .l2 .set (key, value, ttlMs);
return value;
}
}
Step 3: DataLoader for Batch Loading When multiple parts of your app need the same work order, batch and deduplicate:
import DataLoader from 'dataloader' ;
const workOrderLoader = new DataLoader <number , any >(
async (ids : readonly number []) => {
const results = await Promise .all (
ids.map ((id ) =>
client.get (`/workorders/${id} ` ).then ((r ) => r.data )
),
);
return ids.map ((id ) => results.find ((r ) => r.id === id) || null );
},
{
maxBatchSize : 25 ,
cacheKeyFn : (id ) => String (id),
},
);
const [wo1, wo2, wo3] = await Promise .all ([
workOrderLoader.load (100 ),
workOrderLoader.load (200 ),
workOrderLoader.load (100 ),
]);
Step 4: Efficient Pagination
async function efficientFetchAll (client : any , endpoint : string , key : string ) {
const all = [];
let cursor : string | undefined ;
let pageCount = 0 ;
const startTime = Date .now ();
do {
const { data } = await client.get (endpoint, {
params : { limit : 100 , cursor },
});
all.push (...data[key]);
cursor = data.cursor ;
pageCount++;
} while (cursor);
const elapsed = Date .now () - startTime;
console .log (`Fetched ${all.length} items in ${pageCount} pages (${elapsed} ms)` );
return all;
}
async function fetchAllResources (client : any ) {
const [workOrders, assets, locations] = await Promise .all ([
efficientFetchAll (client, '/workorders' , 'workOrders' ),
efficientFetchAll (client, '/assets' , 'assets' ),
efficientFetchAll (client, '/locations' , 'locations' ),
]);
return { workOrders, assets, locations };
}
Step 5: Request Deduplication
class RequestDeduplicator {
private inflight = new Map <string , Promise <any >>();
async dedupe<T>(key : string , fetcher : () => Promise <T>): Promise <T> {
if (this .inflight .has (key)) {
return this .inflight .get (key)! as Promise <T>;
}
const promise = fetcher ().finally (() => {
this .inflight .delete (key);
});
this .inflight .set (key, promise);
return promise;
}
}
const dedup = new RequestDeduplicator ();
async function getWorkOrder (id : number ) {
return dedup.dedupe (`wo:${id} ` , () => client.get (`/workorders/${id} ` ));
}
Performance Benchmarks Optimization Before After Improvement Connection pooling 350ms/req 150ms/req 57% faster L1 cache (hot path) 150ms/req < 1ms/req 99% faster DataLoader batching 10 calls 1 call 90% fewer requests Max page size (100) 50 pages 10 pages 5x fewer round trips Request dedup N calls 1 call (N-1) saved
Output
Connection pooling with keep-alive (reuses TCP connections)
Multi-level cache (L1 in-memory + L2 Redis)
DataLoader for batching and deduplication of entity fetches
Efficient pagination with max page sizes
Request deduplication preventing redundant concurrent calls
Error Handling Issue Cause Solution Stale cache data TTL too long Reduce TTL, invalidate on writes Memory growth Unbounded cache Set max size, use LRU eviction DataLoader errors One item in batch fails Handle per-item errors in batch function Connection pool exhaustion Too many concurrent requests Increase maxSockets or add queue
Resources
Next Steps For cost optimization, see maintainx-cost-tuning.
Examples Benchmark your API response times :
for i in $(seq 1 10); do
curl -s -o /dev/null -w "Request $i : %{time_total}s\n" \
"https://api.getmaintainx.com/v1/workorders?limit=1" \
-H "Authorization: Bearer $MAINTAINX_API_KEY "
done