Load Testing & Performance
Relevant source files
The following files were used as context for generating this wiki page:
The Load Testing and Performance framework provides a comprehensive suite of tools and automated agents to ensure the NeXifyAI platform maintains high availability and meets strict Service Level Agreements (SLAs). This system validates the performance of the Brain API, 9Router, and Gateway components under various stress scenarios including smoke, load, stress, and soak tests.
Performance metrics are continuously monitored by autonomous agents like the senior-quality-auditor and quality-engineer, who enforce quality gates and generate tasks when health deviations occur. This ensures that every deployment meets the required latency and throughput standards before reaching production.
Performance Architecture & Metrics
The platform utilizes a distributed testing architecture targeting three primary services: the Brain API (port 8420), 9Router (port 20128), and the Gateway (port 8642).
Performance Targets and SLAs
The platform defines specific thresholds for P99 latency and error rates to maintain enterprise-grade reliability.
| Service | Endpoint | Target Load | P99 Threshold | Error Rate |
|---|---|---|---|---|
| Brain API | /v1/query | 100 RPS | ≤ 50ms | ≤ 1% |
| 9Router | /v1/chat | 50 RPS | ≤ 2000ms | ≤ 5% |
| Gateway | /health | 200 RPS | ≤ 200ms | ≤ 1% |
Sources: [tests/load/nexify-loadtest.js:1-40](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/tests/load/nexify-loadtest.js#L1-L40), [services/api/agents/brain_agents/senior-quality-auditor.md:58-64](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/services/api/agents/brain_agents/senior-quality-auditor.md#L58-L64)
Automated Quality Gates
The senior-quality-auditor enforces "Gate 5 — Performance" during the deployment lifecycle. It mandates the following benchmarks:
- API Latency: <200ms p95.
- Agent Response: <5s.
- Resource Usage: CPU and Memory <80%.
- Database Query: <100ms p95.
Sources: [services/api/agents/brain_agents/senior-quality-auditor.md:58-64](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/services/api/agents/brain_agents/senior-quality-auditor.md#L58-L64)
Load Testing Scenarios
The platform uses k6 to execute four primary test types, each designed to validate different aspects of system stability.
The diagram above illustrates the flow from load test selection to final deployment approval or task generation.
Sources: [tests/load/nexify-loadtest.js:77-167](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/tests/load/nexify-loadtest.js#L77-L167), [services/api/agents/brain_agents/senior-quality-auditor.md:42-50](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/services/api/agents/brain_agents/senior-quality-auditor.md#L42-L50)
Test Definitions
- Smoke Test: Verifies basic connectivity and health using 2 Virtual Users (VUs) for 30 seconds.
- Load Test: Simulates typical production traffic by ramping VUs up to 100 for Brain and 200 for Gateway.
- Stress Test: Pushes the system to its limits (up to 600 VUs for Gateway) to identify breaking points.
- Soak Test: Validates long-term stability and memory leaks by maintaining constant load for 10 minutes.
Sources: [tests/load/nexify-loadtest.js:77-167](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/tests/load/nexify-loadtest.js#L77-L167), [scripts/loadtest-brain-api.js:15-38](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/scripts/loadtest-brain-api.js#L15-L38)
Autonomous Performance Monitoring
The TaskGenerator in the backend autonomously identifies performance and availability issues by scanning health metrics and logs.
Health Scoring
A health-score script calculates a system-wide percentage. If the score falls below 50%, a P0 Critical task is generated. The monitoring logic checks:
backend_alive: Boolean status of the API.uptime: Percentage of successful requests.connection_health: Status of internal service communications.
Sources: [services/api/brain/autonomous_task_gen.py:73-98](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/services/api/brain/autonomous_task_gen.py#L73-L98), [apps/web/public/health.html:150-180](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/apps/web/public/health.html#L150-L180)
Quality Engineer Workflow
The quality-engineer skill performs specific performance tasks during review cycles:
- Analyzes performance metrics from load test results.
- Identifies bottlenecks in critical paths.
- Stores performance patterns in the Brain for future reference.
- Flags maintainability concerns if performance optimization is required.
Sources: [services/api/agents/skill_registry/skills/quality-engineer/SKILL.md:20-40](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/services/api/agents/skill_registry/skills/quality-engineer/SKILL.md#L20-L40)
Metrics Collection and Reporting
Load tests generate custom metrics to provide deep visibility into specific component behaviors.
| Metric Name | Type | Description |
|---|---|---|
brain_query_time | Trend | Latency of Brain search queries. |
router_response_time | Trend | Latency of LLM completions through 9Router. |
gateway_response_time | Trend | Latency of the TCP proxy/gateway. |
brain_errors | Rate | Percentage of failed Brain API requests. |
total_requests | Counter | Cumulative count of all requests made during a test. |
Sources: [tests/load/nexify-loadtest.js:13-21](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/tests/load/nexify-loadtest.js#L13-L21), [tests/loadtest.js:5-11](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/tests/loadtest.js#L5-L11)
Summary Generation
At the end of a test run, the handleSummary function generates a JSON report (stored at /tmp/nexify-loadtest-result.json) and a text summary. This report includes P50, P90, P95, and P99 percentiles for all monitored trends.
This sequence diagram shows the interaction during a Brain API query load test and how metrics are captured.
Sources: [tests/load/nexify-loadtest.js:235-300](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/tests/load/nexify-loadtest.js#L235-L300), [scripts/loadtest-brain-api.js:68-80](https://github.com/NeXify-AI-by-NeXify-Chat-it-Automat-it/nexifyai-platform/blob/c4b6f85ec1b3e823b3e2d63df28a28dac2d6088b/scripts/loadtest-brain-api.js#L68-L80)
Summary
The NeXifyAI platform integrates rigorous load testing with autonomous auditing to ensure performance standards. By utilizing k6 for diverse traffic scenarios and specialized agents for continuous monitoring, the system proactively identifies and mitigates latency issues. This performance-first approach is verified through 7 distinct quality gates, ensuring only certified, high-performing systems reach production.