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

satellite

v0.0.2

Published

Extensions for node-http-proxy

Downloads

67

Readme

Satellite

Extensions for Nodejitsu's node-http-proxy library.

What is it for?

Satellite uses Nodejitsu's node-http-proxy to help with:

  • Load-balancing requests across multiple servers via a round-robin strategy.
  • Supporting sticky sessions by routing requests to specific servers.

And in the future...

  • Being able to add or remove servers from the proxy list on-the-fly.
  • Running the proxy server over multiple CPU cores using Node.js' cluster API.

Installation

npm install satellite

Usage (round-robin)

Let's say you have an application which has multiple instances running on different servers, and you want to setup a proxy server to load-balance requests across those servers.

Satellite provides a round-robin strategy that you can apply to your existing proxy server code:

    // This example demonstrates proxying requests between
    // 2 servers
    var httpProxy   = require('http-proxy');
    var satellite   = require('satellite');

    // Add 2 different servers to the proxy list
    satellite.addAddress({host: '111.11.111.111', port: 80}, function(res){});
    satellite.addAddress({host: '222.22.222.222', port: 80}, function(res){});

    var proxyServer = httpProxy.createServer(

      // tell the proxy serve to use a connect-compatible 
      // middleware that provides round-robin support.
      satellite.roundRobinStrategy,

      function (req,res, proxy){

        // tell proxyRequest to use the target address
        // determined by satellite, which will be one
        // of the 2 servers.
        satellite.store.targetAddress.get( function(targetAddress) {
          proxy.proxyRequest(req, res, targetAddress);
        });
        
      }
    ).listen(80);

Your proxy server will now distribute requests to the servers in a round-robin fashion.

Usage (sticky-session support)

Some application setups require sticky-session support.

For more info on sticky sessions and why you would use them, see the explanation provided in the Readme on SockJS' github repository.

To enable sticky session support in your proxy server, you can do this:

    // This example demonstrates using sticky session
    // support
    var httpProxy   = require('http-proxy');
    var satellite   = require('satellite');

    // Add 2 different servers to the proxy list
    satellite.addAddress({host: '111.11.111.111', port: 80});
    satellite.addAddress({host: '222.22.222.222', port: 80});

    var proxyServer = httpProxy.createServer(

      // tell the proxy server to use sticky-session support. 
      satellite.stickySessionStrategy,

      function (req,res, proxy){
        satellite.store.targetAddress.get( function(targetAddress) {
          proxy.proxyRequest(req, res, targetAddress);
        });
      }
    ).listen(80);

NOTE: If you wish to use both round-robin and sticky-session support in your application, make sure that you call the sticky-session middleware after you have called the round-robin middleware, like this:

    var proxyServer = httpProxy.createServer(
      satellite.roundRobinStrategy,
      satellite.stickySessionStrategy,

Redis store

At the moment, there is a Redis store option in active development (in order to support use of Node.js's cluster API with satellite). There is a hanging request issue which I am yet to resolve, so I will keep working at this until it is fixed.

Dependencies

Satellite was built against Node.js v0.6.17, and has it's engine set against that version.

It may be able to run on previous versions of Node.js, but you'll need to git clone a copy and modify the package.json to do so.

Because there is also a Redis store in development, Redis is an optional dependency.

License

MIT

&copy 2012 Paul Jensen