{"id":15960448,"url":"https://github.com/pubkey/sticky-load-balancer","last_synced_at":"2025-05-07T05:49:32.198Z","repository":{"id":57370921,"uuid":"43395392","full_name":"pubkey/sticky-load-balancer","owner":"pubkey","description":"NPM-Module for Nodejs to create a loadbalancer with a sticky-strategie. ","archived":false,"fork":false,"pushed_at":"2024-01-02T16:23:33.000Z","size":30,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T05:49:26.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pubkey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-29T21:25:40.000Z","updated_at":"2024-01-09T00:31:56.000Z","dependencies_parsed_at":"2024-10-23T15:13:16.060Z","dependency_job_id":null,"html_url":"https://github.com/pubkey/sticky-load-balancer","commit_stats":{"total_commits":30,"total_committers":4,"mean_commits":7.5,"dds":"0.30000000000000004","last_synced_commit":"db7d41b2460ad194fb2d949ac36dbf2d4e1f20bc"},"previous_names":["danielsun174/sticky-load-balancer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubkey%2Fsticky-load-balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubkey%2Fsticky-load-balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubkey%2Fsticky-load-balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubkey%2Fsticky-load-balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pubkey","download_url":"https://codeload.github.com/pubkey/sticky-load-balancer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252823693,"owners_count":21809709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T15:02:51.052Z","updated_at":"2025-05-07T05:49:32.173Z","avatar_url":"https://github.com/pubkey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NOTICE\nThis project is unmaintained.\nIt is currently working as it should and I used it in production with over 250.000 requests/day on a single server.\nThe problem is that the code is ugly, the usage of `farmhash` is unnecessary. There are no tests. There is no support for websockets. So if you want to help refactoring, make [contact](https://twitter.com/pubkeypubkey).\nIf you want to use the current version, feel save, semver is and will be satisfied.\n\n# sticky-load-balancer\nModule for nodejs v4+ to create a loadbalancer with a sticky-strategie.\n\n# custom sticky strategies\nCreate own sticky strategies to distribute requests depending on the incoming data. ( cookies, headers, GET, body.. )\n\n# Dependencies\nThis module needs the npm-module 'farmhash'. To use this you need a python compiler.\nFor Linux you can run the following commands to install it. With windows you are screwed.\n```{r, engine='bash', count_lines}\napt-get install build-essential\napt-get install python\napt-get install g++\nnpm install node-gyp -g\n```\n\n# Installation\n`npm install sticky-load-balancer --save`\n\n# Visit\n[npm](https://www.npmjs.com/package/sticky-load-balancer) | \n[github](https://github.com/pubkey/sticky-load-balancer)\n\n# Example Code\n```js\nStickyLoadBalancer = require('sticky-load-balancer');\n\n//set loggin to active\nStickyLoadBalancer.setLogging(true);\n\n//create new balancer\nvar balancer = new StickyLoadBalancer('127.0.0.1', 5555);\n\n/**\n * this must be unique if you chain multiple balancers together.\n * @default Math.random()^5\n */\nbalancer.setIdentifier('foooooobar');\n\n/**\n * define which parts of a request should be take to create your sticky strategie.\n */\nbalancer.setStickyStrategy([\n    'url',\n    'body.foo',\n    'body.foobar',\n    'headers.user-agent',\n    'cookie.foo'\n]);\n\n//start the balancer\nbalancer.start();\n```\n\n\n# Example Code to remotely add one node to the balancer\n```js\nStickyLoadBalancer = require('sticky-load-balancer');\n/**\n * tell the balancer that this node exists\n */\nStickyLoadBalancer.tellBalancer(\n    {\n        //stats of the balancer\n        ip: '127.0.0.1',\n        port: 5555,\n        identifier: 'foooooobar'\n    },\n    {\n        //stats of the node\n        ip: '127.0.0.1',\n        port: 80,\n        balance: 6\n    }\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpubkey%2Fsticky-load-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpubkey%2Fsticky-load-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpubkey%2Fsticky-load-balancer/lists"}