⌚保活与负载均衡
将薅羊毛进行到极致
保活
addEventListener('scheduled', event => {
event.waitUntil(handleScheduledEvent(event))
})
async function handleScheduledEvent(event) {
const urls = ['https://aaa.zeabur.app/v1/chat/completions', 'https://bbb.onrender.com/v1/chat/completions']; // Replace with your actual URLs
const body = JSON.stringify({
"messages": [
{
"role": "user",
"content": "在吗"
}
],
"stream": true,
"model": "gpt-4-1106-preview"
});
const headers = {
'Authorization': '12345',
'Content-Type': 'application/json'
};
try {
// Map each URL to a fetch POST request and execute all at once
await Promise.all(urls.map(url =>
fetch(url, { method: 'POST', headers: headers, body: body })
));
console.log('Requests sent successfully');
} catch (error) {
console.error('Error sending requests:', error);
}
}负载均衡
DoH Load Balancer
API Load Balancer
API Redirect and Distribute Traffic
最后更新于