{"id":29178267,"url":"https://github.com/knfs-library/alb","last_synced_at":"2025-07-01T18:33:01.076Z","repository":{"id":273699318,"uuid":"920613570","full_name":"knfs-library/alb","owner":"knfs-library","description":"This package implements a simple application load balancer (ALB) using Node.js's `cluster` module. It helps distribute incoming requests across multiple worker processes while maintaining configurable settings for minimum, maximum, and idle time for workers","archived":false,"fork":false,"pushed_at":"2025-04-17T18:40:17.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-22T07:04:52.174Z","etag":null,"topics":["alb","load-balancer","loadbalancer","nodejs"],"latest_commit_sha":null,"homepage":"","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/knfs-library.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-22T13:19:41.000Z","updated_at":"2025-04-17T18:36:48.000Z","dependencies_parsed_at":"2025-01-22T13:32:05.478Z","dependency_job_id":"8773efd9-5002-47a7-a0bf-128e93d6550c","html_url":"https://github.com/knfs-library/alb","commit_stats":null,"previous_names":["knfs-library/alb"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/knfs-library/alb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knfs-library%2Falb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knfs-library%2Falb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knfs-library%2Falb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knfs-library%2Falb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knfs-library","download_url":"https://codeload.github.com/knfs-library/alb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knfs-library%2Falb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263017193,"owners_count":23400447,"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":["alb","load-balancer","loadbalancer","nodejs"],"created_at":"2025-07-01T18:31:17.284Z","updated_at":"2025-07-01T18:33:01.054Z","avatar_url":"https://github.com/knfs-library.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1\u003e \u003cspan style=\"color:#013C4D;\"\u003eAbout\u003c/span\u003e \u003cspan style=\"color:#2B7F84;\"\u003eKnfs ALB\u003c/span\u003e\u003c/h1\u003e\n\u003ca href=\"https://img.shields.io/github/license/knfs-library/alb\" alt=\"License\"\u003e\n\t\u003cimg src=\"https://img.shields.io/github/license/knfs-library/alb\" alt=\"License\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://img.shields.io/github/contributos/knfs-library/alb\" alt=\"License\"\u003e\n\t\u003cimg src=\"https://img.shields.io/github/contributors/knfs-library/alb\" alt=\"License\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://img.shields.io/github/languages/code-size/knfs-library/alb\" alt=\"License\"\u003e\n\t\u003cimg src=\"https://img.shields.io/github/languages/code-size/knfs-library/alb\" alt=\"License\" /\u003e\n\u003c/a\u003e\n\n### A simple application load balancer (ALB) for Node.js\n\nThis package implements a simple application load balancer (ALB) using Node.js's `cluster` module. It helps distribute incoming requests across multiple worker processes while maintaining configurable settings for minimum, maximum, and idle time for workers. This is ideal for scaling applications on multi-core systems.\n\n---\n\n## Install\n\nTo install the package, use either `npm` or `yarn`:\n\n```bash\nnpm i @knfs-tech/alb\n# or\nyarn add @knfs-tech/alb\n```\n\n## Usage\nYou can integrate the ALB into your Node.js app by following the example below:\n\n```javascript\nconst express = require(\"express\");\nconst app = express();\n\nconst alb = require(\"@knfs-tech/alb\");\nconst port = 3000;\n\n// Define a simple route\napp.get('/', (req, res) =\u003e {\n  process.send({ type: 'request_handled' });\n  console.log(`${process.pid}`);\n  res.send(`Handled by worker ${process.pid}`);\n});\n\n// Run the app\nconst runApp = () =\u003e {\n  app.listen(port, () =\u003e {\n    console.log(\"App is running on port 3000\");\n  });\n};\n\n// Start the ALB with your app and configuration\nalb(runApp, {\n  max: 4, // Maximum number of worker processes\n  min: 2  // Minimum number of worker processes\n});\n```\n\nThis code sets up a load balancer with the specified configurations. The alb module will manage the worker processes and ensure that the application is efficiently scaled across multiple CPU cores.\n\n## Configuration\nYou can customize the following options in the configuration object:\n\n- **max**: Maximum number of worker processes (default: number of CPU cores available).\n- **min**: Minimum number of worker processes to maintain (default: 2).\n- **idleTime**: Maximum idle time (in milliseconds) for a worker before it is terminated (default: 30,000ms).\n- **log**: \u003cboolean\u003e Log when run\n\n## Author\n* [Kent Phung](https://github.com/khapu2906)\n  \n## Owner\n* [Knfs.,jsc](https://github.com/knfs-library)\n\n## More\n\n## License\n\nBamimi is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknfs-library%2Falb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknfs-library%2Falb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknfs-library%2Falb/lists"}