Queue and batch HTTP requests
✓Works with OpenClaudeYou are a backend engineer implementing an HTTP request queue system. The user wants to queue and batch HTTP requests efficiently with configurable concurrency and retry logic.
What to check first
- Verify you have a Node.js HTTP client installed:
npm list axiosornpm list node-fetch - Check your target concurrency limit (how many simultaneous requests you can handle)
Steps
- Create a queue class that stores pending requests with metadata (URL, method, payload, priority)
- Implement a worker pool that processes requests up to a max concurrency limit
- Add batch grouping logic to combine multiple requests into single payloads when beneficial
- Implement exponential backoff retry mechanism with jitter for failed requests
- Use async/await with Promise.all() to handle concurrent request execution within limits
- Track request state (pending, in-progress, completed, failed) and expose queue status
- Add a flush method to force immediate processing of all queued items
- Emit events or callbacks when requests complete or fail for observability
Code
const EventEmitter = require('events');
const axios = require('axios');
class RequestQueue extends EventEmitter {
constructor(options = {}) {
super();
this.maxConcurrency = options.maxConcurrency || 3;
this.maxRetries = options.maxRetries || 3;
this.batchSize = options.batchSize || null;
this.batchDelay = options.batchDelay || 100;
this.queue = [];
this.inProgress = 0;
this.batchTimer = null;
}
add(request) {
const task = {
id: Math.random().toString(36),
url: request.url,
method: request.method || 'GET',
data: request.data || null,
headers: request.headers || {},
priority: request.priority || 0,
retries: 0,
timestamp: Date.now(),
};
this.queue.push(task);
this.queue.sort((a, b) => b.priority - a.priority);
if (this.batchSize) {
clearTimeout(this.batchTimer);
if (this.queue.length >= this.batchSize) {
this.process();
} else {
this.batchTimer = setTimeout(() => this.process(), this.batchDelay);
}
} else {
this.process();
}
return task.id;
}
async process() {
while (this.queue.length > 0 && this.inProgress < this.maxConcurrency) {
const task = this.queue.shift();
this.inProgress++;
this.executeTask(task);
}
}
async executeTask(task) {
try {
const response = await axios({
method
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Networking Skills
Other Claude Code skills in the same category — free to download.
HTTP Client
Create configured HTTP client with interceptors
Retry Logic
Implement retry logic with exponential backoff
Circuit Breaker
Implement circuit breaker pattern
Proxy Setup
Set up reverse proxy configuration
SSL Setup
Configure SSL/TLS certificates
DNS Setup
Configure DNS records
Load Balancer
Set up load balancing configuration
Nginx Reverse Proxy
Configure Nginx as reverse proxy with upstream servers
Want a Networking skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.