Optimize Langfuse tracing performance for high-throughput applications.
Use when experiencing latency issues, optimizing trace overhead,
or scaling Langfuse for production workloads.
Trigger with phrases like "langfuse performance", "optimize langfuse",
"langfuse latency", "langfuse overhead", "langfuse slow".
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Optimize Langfuse tracing performance for high-throughput applications.
Use when experiencing latency issues, optimizing trace overhead,
or scaling Langfuse for production workloads.
Trigger with phrases like "langfuse performance", "optimize langfuse",
"langfuse latency", "langfuse overhead", "langfuse slow".
// v3: Direct configurationconst langfuse = newLangfuse({
flushAt: 100, // Larger batchesflushInterval: 10000, // Less frequent flushesrequestTimeout: 30000, // Allow time for large batches
});
Setting
Low Volume
High Volume
Ultra-High
Batch size
15
50-100
200
Flush interval
5s
10s
30s
Queue size
1024
4096
8192
Step 3: Non-Blocking Trace Wrapper
Ensure tracing never blocks your application's critical path:
import { observe, updateActiveObservation } from"@langfuse/tracing";
// The observe wrapper is already non-blocking for the trace submission.// But protect against SDK crashes:function safeObserve<T extends (...args: any[]) => Promise<any>>(
name: string,
fn: T
): T {
return (async (...args: Parameters<T>) => {
try {
returnawaitobserve({ name }, async () => {
updateActiveObservation({ input: args });
const result = awaitfn(...args);
updateActiveObservation({ output: result });
return result;
})();
} catch (error) {
// If tracing throws, run function without tracingconsole.warn(`Tracing failed for ${name}:`, error);
returnfn(...args);
}
}) as T;
}
Step 4: Payload Size Optimization
Large trace payloads slow down flush and increase costs: