maintainx-performance-tuning

0
0
Source

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".

Install

mkdir -p .claude/skills/maintainx-performance-tuning && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8852" && unzip -o skill.zip -d .claude/skills/maintainx-performance-tuning && rm skill.zip

Installs to .claude/skills/maintainx-performance-tuning

About this skill

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

// src/performance/pooled-client.ts
import axios from 'axios';
import http from 'node:http';
import https from 'node:https';

// Reuse TCP connections instead of opening new ones per request
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,
});

// Benefit: Eliminates TCP handshake + TLS negotiation per request
// Typical improvement: 100-200ms saved per request

Step 2: Multi-Level Caching

// src/performance/cache.ts

interface CacheLayer<T> {
  get(key: string): Promise<T | undefined>;
  set(key: string, value: T, ttlMs: number): Promise<void>;
}

// L1: In-memory (fastest, per-process)
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 });
  }
}

// L2: Redis (shared across processes)
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));
  }
}

// Multi-level cache: check L1 first, then L2, then fetch
class MultiCache<T> {
  constructor(private l1: CacheLayer<T>, private l2: CacheLayer<T>) {}

  async getOrFetch(key: string, ttlMs: number, fetcher: () => Promise<T>): Promise<T> {
    // Check L1
    let value = await this.l1.get(key);
    if (value !== undefined) return value;

    // Check L2
    value = await this.l2.get(key);
    if (value !== undefined) {
      await this.l1.set(key, value, ttlMs / 2); // L1 shorter TTL
      return value;
    }

    // Fetch from API
    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:

// src/performance/dataloader.ts
import DataLoader from 'dataloader';

const workOrderLoader = new DataLoader<number, any>(
  async (ids: readonly number[]) => {
    // Batch: fetch multiple work orders in parallel
    const results = await Promise.all(
      ids.map((id) =>
        client.get(`/workorders/${id}`).then((r) => r.data)
      ),
    );
    // Return in same order as input ids
    return ids.map((id) => results.find((r) => r.id === id) || null);
  },
  {
    maxBatchSize: 25,
    cacheKeyFn: (id) => String(id),
  },
);

// These 3 calls collapse into 1 batched operation:
const [wo1, wo2, wo3] = await Promise.all([
  workOrderLoader.load(100),
  workOrderLoader.load(200),
  workOrderLoader.load(100), // deduped, same as first
]);

Step 4: Efficient Pagination

// Fetch only the fields you need (if API supports field selection)
// Use larger page sizes to reduce round trips

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 }, // Max page size
    });
    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;
}

// Parallel pagination for independent resources
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

// src/performance/dedup.ts

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();

// 10 concurrent calls to getWorkOrder(123) = 1 actual API call
async function getWorkOrder(id: number) {
  return dedup.dedupe(`wo:${id}`, () => client.get(`/workorders/${id}`));
}

Performance Benchmarks

OptimizationBeforeAfterImprovement
Connection pooling350ms/req150ms/req57% faster
L1 cache (hot path)150ms/req< 1ms/req99% faster
DataLoader batching10 calls1 call90% fewer requests
Max page size (100)50 pages10 pages5x fewer round trips
Request dedupN calls1 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

IssueCauseSolution
Stale cache dataTTL too longReduce TTL, invalidate on writes
Memory growthUnbounded cacheSet max size, use LRU eviction
DataLoader errorsOne item in batch failsHandle per-item errors in batch function
Connection pool exhaustionToo many concurrent requestsIncrease maxSockets or add queue

Resources

Next Steps

For cost optimization, see maintainx-cost-tuning.

Examples

Benchmark your API response times:

# Measure latency for 10 sequential requests
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

d2-diagram-creator

jeremylongshore

D2 Diagram Creator - Auto-activating skill for Visual Content. Triggers on: d2 diagram creator, d2 diagram creator Part of the Visual Content skill category.

6532

svg-icon-generator

jeremylongshore

Svg Icon Generator - Auto-activating skill for Visual Content. Triggers on: svg icon generator, svg icon generator Part of the Visual Content skill category.

9029

automating-mobile-app-testing

jeremylongshore

This skill enables automated testing of mobile applications on iOS and Android platforms using frameworks like Appium, Detox, XCUITest, and Espresso. It generates end-to-end tests, sets up page object models, and handles platform-specific elements. Use this skill when the user requests mobile app testing, test automation for iOS or Android, or needs assistance with setting up device farms and simulators. The skill is triggered by terms like "mobile testing", "appium", "detox", "xcuitest", "espresso", "android test", "ios test".

15922

performing-penetration-testing

jeremylongshore

This skill enables automated penetration testing of web applications. It uses the penetration-tester plugin to identify vulnerabilities, including OWASP Top 10 threats, and suggests exploitation techniques. Use this skill when the user requests a "penetration test", "pentest", "vulnerability assessment", or asks to "exploit" a web application. It provides comprehensive reporting on identified security flaws.

4915

designing-database-schemas

jeremylongshore

Design and visualize efficient database schemas, normalize data, map relationships, and generate ERD diagrams and SQL statements.

12014

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

5110

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,4071,302

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,2201,024

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

9001,013

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

958658

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

970608

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,033496

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.