Juicebox Performance Tuning
Overview
Juicebox's AI analysis API handles dataset uploads, analysis queue wait times, and result pagination. Large dataset uploads (100K+ rows) can block the analysis pipeline, while queue contention during peak hours increases wait times. Result sets from broad queries return thousands of profiles requiring efficient pagination. Caching search results, batching enrichment calls, and managing upload chunking reduces end-to-end analysis time by 40-60% and keeps interactive searches responsive.
Caching Strategy
const cache = new Map<string, { data: any; expiry: number }>();
const TTL = { search: 300_000, profile: 600_000, analysis: 900_000 };
async function cached(key: string, ttlKey: keyof typeof TTL, fn: () => Promise<any>) {
const entry = cache.get(key);
if (entry && entry.expiry > Date.now()) return entry.data;
const data = await fn();
cache.set(key, { data, expiry: Date.now() + TTL[ttlKey] });
return data;
}
// Analysis results are expensive — cache 15 min. Searches expire at 5 min.
Batch Operations
async function enrichBatch(client: any, profileIds: string[], batchSize = 50) {
const results = [];
for (let i = 0; i < profileIds.length; i += batchSize) {
const batch = profileIds.slice(i, i + batchSize);
const res = await client.enrichBatch({ profile_ids: batch, fields: ['skills_map', 'contact'] });
results.push(...res.profiles);
if (i + batchSize < profileIds.length) await new Promise(r => setTimeout(r, 300));
}
return results;
}