C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

Back to Learning Center
Advanced
40 min

Performance Optimization

Optimize your app for 250,000+ req/sec.

Performance Optimization

CanxJS is already fast, but these tips will push it to the limit.

1. Use the JIT Compiler

CanxJS includes an experimental JIT compiler for routes. Enable it in config:

typescript
// src/config/app.ts
export const config = {
  jit: true,
};

2. Optimize Database Queries

Avoid N+1 queries by using eager loading:

typescript
// Bad
const posts = await Post.all();
for (const post of posts) {
  await post.load("author"); // N+1 query
}

// Good
const posts = await Post.with("author").get();

3. Caching

Use the built-in Redis cache for expensive operations:

typescript
import { Cache } from "canxjs";

const stats = await Cache.remember("dashboard_stats", 60, async () => {
    return calculateHeavyStats();
});

Have questions?

Join the discussion on GitHub