> ## Documentation Index
> Fetch the complete documentation index at: https://docs.buntime.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Resource Limits

> Understanding memory, CPU, and timeout constraints

## Overview

Every session has resource limits to ensure fair usage and prevent abuse. Understanding these limits helps you build efficient applications and avoid errors.

## Memory Limits

| Plan       | Memory Per Session |
| ---------- | ------------------ |
| Free       | 1 GB               |
| Paid       | 4 GB               |
| Enterprise | Custom             |

When exceeded:

```json theme={null}
{
  "error": {
    "code": "memory_limit_exceeded",
    "message": "Session exceeded 1GB memory limit"
  }
}
```

## CPU Limits

| Plan       | vCPU Per Session |
| ---------- | ---------------- |
| Free       | 0.25 cores       |
| Paid       | 1 core           |
| Enterprise | Custom           |

CPU is shared and may be throttled under sustained high usage.

## Execution Timeouts

| Plan       | Default | Maximum     |
| ---------- | ------- | ----------- |
| Free       | 30s     | 30s         |
| Paid       | 30s     | 300s (5min) |
| Enterprise | Custom  | Custom      |

Configure per execution:

```typescript theme={null}
await client.execute({
  sessionId: session.id,
  code: '...',
  timeout: 60 // seconds
});
```

## Disk Space

| Plan       | Storage Per Session |
| ---------- | ------------------- |
| Free       | 1 GB                |
| Paid       | 5 GB                |
| Enterprise | Custom              |

Monitor usage:

```typescript theme={null}
await client.execute({
  sessionId: session.id,
  code: `
    const result = Bun.spawnSync(['du', '-sh', '/workspace']);
    console.log(result.stdout.toString());
  `
});
```

## Concurrent Sessions

| Plan       | Max Concurrent |
| ---------- | -------------- |
| Free       | 10             |
| Paid       | 100            |
| Enterprise | Custom         |

## Request Rate Limits

| Plan       | Requests/Minute |
| ---------- | --------------- |
| Free       | 100             |
| Paid       | 1,000           |
| Enterprise | Custom          |

Rate limit headers:

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
```

## File Limits

| Resource          | Free      | Paid      | Enterprise |
| ----------------- | --------- | --------- | ---------- |
| Max file size     | 10 MB     | 50 MB     | Custom     |
| Files per request | 100       | 1,000     | Custom     |
| Total files       | Unlimited | Unlimited | Unlimited  |

## Best Practices

<CardGroup cols={2}>
  <Card title="Monitor usage" icon="chart-line">
    Check execution metrics to optimize resource usage
  </Card>

  <Card title="Set timeouts" icon="clock">
    Use appropriate timeouts for different operations
  </Card>

  <Card title="Clean up files" icon="broom">
    Delete unused files to stay within disk limits
  </Card>

  <Card title="Optimize code" icon="code">
    Efficient code uses fewer resources
  </Card>
</CardGroup>
