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 🙏

© 2024 – Pkg Stats / Ryan Hefner

aset

v0.1.0

Published

Scalable Redis Sorted Sets

Downloads

2

Readme

ASet - Scalable Redis Sorted Sets

Redis Sorted Sets that scales.

WARNING! Highly experimental. Use at your own risk!

INTRO

To see what problem ASet is tackling, please read ASet — scaling sorted sets

REQUIREMENTS

  • Node.js v6+
  • Redis v4+

INSTALLATION

npm install aset

USAGE

const ASet = require("aset")  
 
const setKey = "foo"
 
// Minimum recommended config (4 servers) 
const clientOptions = {
    c1: {
        ared: {
            s1: {
                host: "127.0.0.1",
                port: 8124,
                redis: {
                    r1: {
                        host: "127.0.0.1",
                        port: 6379
                    }
                }
            },
            s2: {
                host: "127.0.0.1",
                port: 8125,
                redis: {
                    r2: {
                        host: "127.0.0.1",
                        port: 6380
                    }
                }
            }
        },
        replication: 2,
        writePolicy: 2
    },
    c2: {
        ared: {
            s3: {
                host: "127.0.0.1",
                port: 8126,
                redis: {
                    r1: {
                        host: "127.0.0.1",
                        port: 6381
                    }
                }
            },
            s4: {
                host: "127.0.0.1",
                port: 8127,
                redis: {
                    r2: {
                        host: "127.0.0.1",
                        port: 6382
                    }
                }
            }
        },
        replication: 2,
        writePolicy: 2
    }
}
    
const aset = new ASet(clientOptions, setKey, () => {
    const score = 101
    const member = "bar"
    
    aset.add(score, member, (error, result) => {
        if (error) {
            throw error
        }
        
        console.log(result) // OK
    })
    
    // OR
    
    aset.get((error, result) => {
        if (error) {
            throw error
        }
        
        console.log(result) // [score, member]             
    })
})

SCALING

  • c1, c2, c* are into how many pieces the sorted set will be split. Add more to scale write performance.
  • s1, s2, s* are servers used for replication. Add more to scale read performance.
  • r1, r2, r* are just Redis instances. Add as many per server as cores are available.
  • It is important that all c, s and r are unique (due to ARed requirements).
  • Currently if you change s and r, you need to use ARed rebalancer. But if you change c you will need to rebalance data manually.

BEST PRACTICES

  • It's better to separate ADD and GET. This way, in case you only have 1 GET process, it will perform at it's max.
  • You can scale ADD by adding more of the processes. I recommend using PM2 and a reverse proxy with NGINX for that.
  • You can only scale GET if order of the results is not important or you have your own mechanism to ensure the order.

TESTING

NOTE: Requires Redis (localhost and ports 6379-6832) to be installed (4 instances for full testing)

npm test

LINTING

npm run lint

CONTRIBUTING

Go nuts! Just don't forget to test and lint. Credit will be given where it's due.

FUTURE

  • Create rebalancer.
  • Benchmarks
  • Lots of fixes and optimizations