npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mnmadhukar/node-spqs

v1.0.0

Published

A priority queue service built on top of AWS SQS with Redis for priority management

Readme

Simple Priority Queue Service for AWS SQS

A Node.js library that provides a priority queue implementation on top of AWS SQS, using Redis for priority management.

Features

  • Priority-based message processing with at least 3 distinct priority levels (0 being highest)
  • FIFO ordering within the same priority level
  • Standard SQS message operations (send, receive, delete)
  • Dynamic priority assignment at message creation time
  • Prevention of starvation for lower-priority messages
  • Metrics for queue depth and processing latency by priority level

Installation

npm install @mnmadhukar/node-spqs
# or
yarn add @mnmadhukar/node-spqs
# or
pnpm add @mnmadhukar/node-spqs

Requirements

  • Node.js 14.x or higher
  • AWS account with SQS access
  • Redis server (v4.x or higher)

Usage

Basic Setup

import { PriorityQueueService } from 'simple-priority-queue-service';

// Initialize the service
const queueService = new PriorityQueueService({
  region: process.env.AWS_REGION || 'ap-south-1',
  queueUrl: 'https://sqs.ap-south-1.amazonaws.com/123456789012/my-queue',
  redisUrl: 'redis://localhost:6379',
  priorityLevels: 3, // 0, 1, 2 (0 being highest priority)
});

// Connect to services
await queueService.connect();

Sending Messages

// Send a message with priority
await queueService.sendMessage({
  body: 'Hello, world!',
  priority: 0, // High priority
});

// Send a message with medium priority
await queueService.sendMessage({
  body: 'Less urgent message',
  priority: 1, // Medium priority
});

// Send a message with low priority
await queueService.sendMessage({
  body: 'Low priority message',
  priority: 2, // Low priority
});

Receiving Messages

// Receive messages (automatically prioritized)
const messages = await queueService.receiveMessages({
  maxMessages: 10,
});

// Process messages
for (const message of messages) {
  console.log(`Processing message with priority ${message.priority}: ${message.body}`);
  
  // After processing, delete the message
  await queueService.deleteMessage(message.receiptHandle);
}

Cleanup

// Disconnect when done
await queueService.disconnect();

Advanced Configuration

const queueService = new PriorityQueueService({
  region: process.env.AWS_REGION || 'ap-south-1',
  queueUrl: 'https://sqs.ap-south-1.amazonaws.com/123456789012/my-queue',
  redisUrl: 'redis://localhost:6379',
  priorityLevels: 5, // 0, 1, 2, 3, 4
  
  // Advanced options
  visibilityTimeout: 30, // seconds
  waitTimeSeconds: 20, // for long polling
  starvationPreventionThreshold: 100, // Process lower priority after this many messages
  
  // AWS SDK options
  awsConfig: {
    accessKeyId: 'YOUR_ACCESS_KEY',
    secretAccessKey: 'YOUR_SECRET_KEY',
  },
});

Monitoring

The service provides built-in metrics that can be accessed:

// Get queue depth by priority
const queueDepth = await queueService.getQueueDepthByPriority();
console.log(queueDepth); // { 0: 5, 1: 10, 2: 20 }

// Get processing latency by priority
const latency = await queueService.getProcessingLatencyByPriority();
console.log(latency); // { 0: 120, 1: 350, 2: 780 } (in ms)

Architecture

This library uses:

  • AWS SQS for reliable message storage and delivery
  • Redis for tracking message priorities and ensuring priority-based processing
  • A single SQS queue with Redis-based priority management (no multiple queues)

License

MIT