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

# Performance Optimization

> Optimize Lumina for high-throughput workloads

## Ingestion

**Batch traces client-side:**

```typescript theme={null}
const lumina = initLumina({
  endpoint: 'http://lumina:9411/v1/traces',
  service_name: 'high-volume',
  batchSize: 100,
  batchTimeout: 1000,
});
```

**Enable compression:**

```bash theme={null}
ENABLE_COMPRESSION=true
```

**Scale horizontally:**

```bash theme={null}
kubectl scale deployment lumina-ingestion --replicas=10
```

***

## Queries

**Enable caching:**

```bash theme={null}
ENABLE_QUERY_CACHE=true
CACHE_TTL_SECONDS=60
```

**Optimize indexes:**

```sql theme={null}
CREATE INDEX CONCURRENTLY idx_traces_service_timestamp
ON traces (service_name, timestamp DESC);
```

***

## Database

**Tune PostgreSQL:**

```sql theme={null}
ALTER SYSTEM SET shared_buffers = '4GB';
ALTER SYSTEM SET work_mem = '64MB';
ALTER SYSTEM SET effective_cache_size = '16GB';
SELECT pg_reload_conf();
```

***

## Sampling

For very high volumes:

```typescript theme={null}
const lumina = initLumina({
  endpoint: 'http://lumina:9411/v1/traces',
  service_name: 'ultra-high-volume',
  samplingRate: 0.1,
  alwaysSampleConditions: {
    error: true,
    costUsd: { $gt: 0.5 },
  },
});
```
