Spaces:
Running
Running
Download queue_load_test.js from hari7775/resume-server: direct link, hf CLI and curl.
- Browser
- Download file 2.57 kB
-
https://huggingface.co/spaces/hari7775/resume-server/resolve/main/queue_load_test.js
- Command line
-
hf download hf://spaces/hari7775/resume-server/queue_load_test.js
-
curl -L -o queue_load_test.js https://huggingface.co/spaces/hari7775/resume-server/resolve/main/queue_load_test.js
2.57 kB
| const FIREBASE_API_KEY = 'AIzaSyCZsz4v9a9ioF5uhK2bACy8xea6iIhSZCQ'; | |
| const SERVER_URL = 'https://hari7775-resume-server.hf.space'; | |
| async function run() { | |
| console.log('1. Starting massive 100-job stress test to fill server queue backlog...'); | |
| // Pre-generate tokens in batches of 10 | |
| console.log('Generating 100 Firebase tokens...'); | |
| const tokens = []; | |
| for (let b = 0; b < 10; b++) { | |
| const authBatch = Array.from({ length: 10 }).map(() => | |
| fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${FIREBASE_API_KEY}`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ returnSecureToken: true }) | |
| }).then(r => r.json()).then(d => d.idToken) | |
| ); | |
| const resolved = await Promise.all(authBatch); | |
| tokens.push(...resolved); | |
| } | |
| console.log(`โ ${tokens.length} tokens ready!`); | |
| console.log('\n๐ Dispatching 100 heavy PDF generation requests to server...'); | |
| const jobs = tokens.map((token, idx) => { | |
| const i = idx + 1; | |
| const html = `<!DOCTYPE html><html> | |
| <head> | |
| <link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap" rel="stylesheet"> | |
| </head> | |
| <body style="width:794px;height:1123px;padding:40px;font-family:'Merriweather',serif;"> | |
| <h1>Massive Queue Backlog Stress Job #${i} - ${Date.now()}-${Math.random()}</h1> | |
| <p>Testing sustained backlog position # under 100 concurrent job load.</p> | |
| <div style="height:350px;background:#f3f4f6;border:2px solid #e5e7eb;border-radius:12px;margin-top:20px;"></div> | |
| <div style="height:350px;background:#e5e7eb;border:2px solid #d1d5db;border-radius:12px;margin-top:20px;"></div> | |
| </body></html>`; | |
| return fetch(`${SERVER_URL}/api/export-pdf`, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Authorization': `Bearer ${token}` | |
| }, | |
| body: JSON.stringify({ | |
| html, | |
| metadata: { filename: `massive_load_${i}` } | |
| }) | |
| }).then(r => r.json()).then(d => { | |
| if (i % 10 === 0 || i <= 5) { | |
| console.log(`[Job #${i}/100] Server Queue Position: #${d.position} (ID: ${d.jobId?.slice(0, 8)})`); | |
| } | |
| return d; | |
| }).catch(e => { | |
| console.error(`Job #${i} error:`, e.message); | |
| }); | |
| }); | |
| console.log('\n๐ฅ 100 requests DISPATCHED! The server queue backlog will stay active for ~1-2 minutes! Click Export PDF in your browser now!'); | |
| await Promise.all(jobs); | |
| console.log('\nโ All 100 jobs finished processing!'); | |
| } | |
| run(); | |