{"id":18084996,"url":"https://github.com/coderofsalvation/elasticnode","last_synced_at":"2026-05-15T21:39:40.705Z","repository":{"id":146965143,"uuid":"469648776","full_name":"coderofsalvation/elasticnode","owner":"coderofsalvation","description":"lightweight horizontal scaleable nodejs faas boilerplate","archived":false,"fork":false,"pushed_at":"2022-03-28T12:57:51.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T00:13:53.303Z","etag":null,"topics":["baremetal","cluster","faas","horizontal","lightweight","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderofsalvation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-03-14T08:46:51.000Z","updated_at":"2022-03-17T08:28:06.000Z","dependencies_parsed_at":"2023-05-05T23:48:12.037Z","dependency_job_id":null,"html_url":"https://github.com/coderofsalvation/elasticnode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coderofsalvation/elasticnode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Felasticnode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Felasticnode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Felasticnode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Felasticnode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderofsalvation","download_url":"https://codeload.github.com/coderofsalvation/elasticnode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Felasticnode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265222973,"owners_count":23730327,"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":["baremetal","cluster","faas","horizontal","lightweight","loadbalancer","nodejs"],"created_at":"2024-10-31T15:08:59.592Z","updated_at":"2026-05-15T21:39:35.663Z","avatar_url":"https://github.com/coderofsalvation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# horizontal scaleable nodejs boilerplate\n\n```bash\n$ node server.js\n[loadbal|300457|tcp/9999] loadbalancer started\n[service|300469|tcp/5000] cluster-node started on port 5000\n[service|300471|tcp/5001] cluster-node started on port 5001\n[service|300469|tcp/5000] cluster-node connected\n[service|300471|tcp/5001] cluster-node connected\n[loadbal|300457|tcp/9999] initing cluster-app\n[03-16T14:40:27] ├☑ myservice:  connected!          # executed on cluster \n[03-16T14:40:27] ├☑ myservice:  ping!               # executed on cluster \n```\n\n## cluster definition \n\n```json\n{\n  \"master\":  \"./cluster/loadbalancer.js\", \n  \"workers\": {                                   // cpus\n    \"serviceA\":{ \"worker\":\"./service/index.js\", \"count\":1, \"port\":5000 },\n    \"serviceB\":{ \"worker\":\"./service/index.js\", \"count\":1, \"port\":5001 }\n  }, \n  \"remotes\":[\n    { \"host\":\"192.23.4.56\", \"port\":5000 },       // same app but runs on other server\n    { \"host\":\"192.23.4.56\", \"port\":5001 },       // they become workers of this server\n  ], \n  \"remotes\":[], \n  \"accessKey\": \"test\",                           // cluster management over rest/cli\n  \"cli\":false                                    // thanks to npmjs.org/cluster-service\n}\n```\n\n\n\u003e cluster functions:\n\n```js\nconst service = require('./../cluster/service').service('myservice')\n\nservice.module.exports = {\n  async ping () {\n    let app = service.client.methods\n    app.log('ping!', 'myservice')\n    //log('local ping!')\n    return 123\n  }\n}\n\nservice.init = async (app) =\u003e {\n  await app.log(\"connected!\",'myservice')\n  await app.ping()\n}\n```\n\n## scale horizontally \n\n* across cpu's thanks to [cluster-service](https://npmjs.org/cluster-service)\n* across servers thanks to [ezrpc](https://npmjs.org/ezrpc)\n* update/manage workers using REST/cli thanks to [cluster-service](https://npmjs.org/cluster-service)\n\n\u003e when using remotes, use env-var `upstream=main.myserver.org` e.g. on remotes. By doing so, `app.ping()` will run through loadbalancer `main.myserver.org`.\n\n## centralized calls \u0026 data\n\nall workers can execute / save data centrally on `cluster/loadbalancer.js`:\n\n```javascript\nawait app.set(\"foo.bar\",[{x:1}])         // generates db.json\nawait app.get(\"foo.bar\") )               // [{x:1}]\nawait app.find(\"foo.bar\",   {x:{$lt:2}}) // [{x:1}]\nawait app.findOne(\"foo.bar\",{x:{$lt:2}}) // {x:1}\n```\n\n\u003e `db.json` now contains `{foo:{bar:[{x:1}]}}`, which you can easily backup/edit\n\n## decentralized data (proxy-to-jsonfile)\n\nworkers can easily use own databases:\n\n```\nconst db = require('./server/db')({file:'mydb.json', ratelimit:1500})\ndb.accounts = {a:[{foo:1},{foo:2}]}\nlet some = db.find('accounts.a',{foo:{$lt:2}}) )\nlet one  = db.findOne('accounts.a',{foo:{$lt:2}}) )\n```\n\n## Lightweight 55MB all-in-one-V8-binary / docker-image\n\n```javascript\n$ podman build -t elastinode\n$ podman images\nREPOSITORY                   TAG             IMAGE ID       CREATED              SIZE\nelasticnode                  latest          79988bafb26d   32 seconds ago       51.5MB\n$ DOCKER_BUILDKIT=1 docker build -t elasticnode --output out\n$ ls -la out/server\n-rwxr-xr-x 1 44M mrt 16 16:10 out/server\n```\n\n\u003e not bad for a distributed scalable app no?\n\n## test\n\n```javascript\n$ node test/test.js\n[loadbal|301490|tcp/9999] loadbalancer started\n[service|301502|tcp/5000] cluster-node started on port 5000\n[service|301502|tcp/5000] cluster-node connected\n[service|301503|tcp/5001] cluster-node started on port 5001\n[loadbal|301490|tcp/9999] initing cluster-app\n[service|301503|tcp/5001] cluster-node connected\n[ { id: 'projectA',  data: {} },  { id: 'projectB',  data: {} } ]\nconnected \n[03-16T14:50:15] ├☑ myservice:  connected!\n[03-16T14:50:15] ├☑ myservice:  ping!\nOK : app.ping =\u003e 123\ndone\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Felasticnode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderofsalvation%2Felasticnode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Felasticnode/lists"}