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

node-red-contrib-loadbalance

v0.6.0

Published

Node-RED implements a load balancer (router).

Downloads

224

Readme

node-red-contrib-loadbalance loadbalance

Node-Red node to load balance either with static routes or dynamic routes.

Basically spreads input messages to flows based on:

  • Round Robin - next in list then start at being again
  • Hash - Hash art of message to determine route (quasi sticky route)
  • Random - randomly across out paths
  • Fold on capacity - place load on first node in order with capacity. Good for improving cache hit ratios. At full capacity random selection.
  • Next smoothing to average capacity - next that is >= average capacity to get smoothing of load. At full capacity random selection.
  • Persist path states and capacity on recycle in context storage - need to defined content persistence in nodered settings, see https://nodered.org/docs/user-guide/context

This allows incoming messages to be passed to servers that may be other node red instances.

For HTTP sticky can be selected. This stores the path in a cookie and the same path is reused so long as it is available and the cookie information is maintained on message.

Out port zero is used for administration and used to send message if there is no availability in all routes. This allows responses messages or queuing to be managed.

Message per second capacity is visible when capacity based mode is selected. Indicates capacity is many messages per second are allowed.

Default capacity is visible when capacity based mode is selected.

At no capacity is visible when capacity based mode is selected. Allows choice of what is to be done with message when full capacity is reached.

At no availablity allows choice of what is to be done with message when there is no availabilty. Messages either discarded or sent to admin port.

Static paths

Load Balance

Dynamic paths

When paths equal 1 a template in workflow can be selected.

Load Balance Dynamic

Only "http request" types work at this stage and it requires the template to have url set to blank. See test for details.


Management

Messages can be sent to node with the following topics and not forwarded

msg.topic loadbalance

Takes in metrics and availablity for a path in msg.payload in form:

{path: <path number>, capacity: <numeric value>, status: <0=unavailable>} 

or and array of above.

Capacity of zero is considered saturation. Positive values are expected.

Basically a remote node could be constructed to send a message to update

msg.topic loadbalance.list

Will send metadata about queues to admin output port.

msg.topic loadbalance.debug

Will send metadata about queues to error log so visible in debug console.

msg.topic loadbalance.route

If paths set to 1 and template selected enables dynamic routing. Current only "http request" template allowed.
Form of payload {url:"/a/url/path"}

msg.topic loadbalance.save

Persists path metrics and states

msg.topic loadbalance.saveDetails

Content of save metrics


Hash routing

Routing can be based on a hash or a property in the message. See pane below. Either FNV or Pearson hashing technique can be used. If Pearson at most 256 routes are possible as this is the lookup size used. The if an odd number of routes, 1 route will receive proportional less activity based number of routes.

Hash Route Node

Example flow included in test folder.

Hash Route Test Flow


Wish List

  • Alive polling, keep alive can be used to trigger remote to send capacity metrics (note, this could be done by flow)
  • Other dynamic template node types e.g. mq, http out etc.
  • Dynamic addition of paths by discovery (note, this could be done by flow)
  • Some base capacity calls to remote engines (note, this could be done by flow)
  • mps - default base capacity set per path at setup

Install

Run the following command in the root directory of your Node-RED install

npm install node-red-contrib-loadbalance

Tests

Test/example flow in test/testflow.json

Test

Test flow for sticky feature in test/testSticky.json

Test Sticky

Test flow for sticky feature in test/testDynamic.json

Test Dynamic


Version

0.6.0 Persist metrics and paths

0.5.0 Add hash on part of msg to determine path, improve dynamic and fix bug when duplicate path

0.4.0 Initial release

Author

Peter Prib