{"id":21653526,"url":"https://github.com/mrhooray/swim-js","last_synced_at":"2025-04-07T06:06:47.868Z","repository":{"id":26497297,"uuid":"29949668","full_name":"mrhooray/swim-js","owner":"mrhooray","description":"JavaScript implementation of SWIM membership protocol","archived":false,"fork":false,"pushed_at":"2023-05-09T12:39:40.000Z","size":71,"stargazers_count":141,"open_issues_count":2,"forks_count":40,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-31T05:05:30.047Z","etag":null,"topics":["consensus","distributed-systems","failure-prediction","gossip-protocol","javascript","swim"],"latest_commit_sha":null,"homepage":"https://pdfs.semanticscholar.org/8712/3307869ac84fc16122043a4a313604bd948f.pdf","language":"JavaScript","has_issues":false,"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/mrhooray.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":"2015-01-28T03:59:32.000Z","updated_at":"2024-01-14T03:01:07.000Z","dependencies_parsed_at":"2024-06-18T18:17:01.713Z","dependency_job_id":"b1c628d4-ad9c-4370-a51a-6ceab5e3a89e","html_url":"https://github.com/mrhooray/swim-js","commit_stats":{"total_commits":36,"total_committers":7,"mean_commits":5.142857142857143,"dds":"0.36111111111111116","last_synced_commit":"bd3d2f87d60e6fbd8a38f807773dfedf74c7fff0"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fswim-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fswim-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fswim-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrhooray%2Fswim-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrhooray","download_url":"https://codeload.github.com/mrhooray/swim-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601447,"owners_count":20964864,"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":["consensus","distributed-systems","failure-prediction","gossip-protocol","javascript","swim"],"created_at":"2024-11-25T08:18:54.481Z","updated_at":"2025-04-07T06:06:47.842Z","avatar_url":"https://github.com/mrhooray.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swim-js [![Build Status](https://travis-ci.org/mrhooray/swim-js.svg?branch=master)](https://travis-ci.org/mrhooray/swim-js)\n\u003e JavaScript implementation of [SWIM](http://www.cs.cornell.edu/~asdas/research/dsn02-SWIM.pdf) membership protocol\n\n* [npm](https://www.npmjs.com/package/swim)\n* [Motivation](#motivation)\n* [Usage](#usage)\n* [Benchmark](#benchmark)\n* [License](#license)\n\n## Motivation\n\nMembership management is important to distributed systems and large clusters need a decentralized protocol such as SWIM,\n which handles failure detection and membership dissemination in a scalable and weakly-consistent way.\nIt can be used to implement functionalities based on membership like distributed consensus, application layer sharding, log replication, etc.\n\n## Usage\n\nInstallation\n```sh\nnpm install swim --save\n```\n```js\nvar Swim = require('swim');\nvar opts = {\n    local: {\n        host: '10.31.1.191:11000',\n        meta: {'application': 'info'} // optional\n    },\n    codec: 'msgpack', // optional\n    disseminationFactor: 15, // optional\n    interval: 100, // optional\n    joinTimeout: 200, // optional\n    pingTimeout: 20, // optional\n    pingReqTimeout: 60, // optional\n    pingReqGroupSize: 3, // optional\n    suspectTimeout: 60, // optional\n    udp: {maxDgramSize: 512}, // optional\n    preferCurrentMeta: true // optional\n};\nvar swim = new Swim(opts);\nvar hostsToJoin = ['10.31.1.192:11000', '10.31.1.193:11000'];\n\nswim.bootstrap(hostsToJoin, function onBootstrap(err) {\n    if (err) {\n        // error handling\n        return;\n    }\n\n    // ready\n    console.log(swim.whoami());\n    console.log(swim.members());\n    console.log(swim.checksum());\n\n    // change on membership, e.g. new node or node died/left\n    swim.on(Swim.EventType.Change, function onChange(update) {});\n    // update on membership, e.g. node recovered or update on meta data\n    swim.on(Swim.EventType.Update, function onUpdate(update) {});\n\n    // shutdown\n    swim.leave();\n});\n\n// or\nswim.bootstrap(hostsToJoin);\n// bootstrap error handling\nswim.on(Swim.EventType.Error, function onError(err) {});\n// bootstrap ready\nswim.on(Swim.EventType.Ready, function onReady() {});\n```\n\n[Additional API Documentation](docs/api.md)\n\n## Benchmark\n\nBenchmark convergence time under different configuration\n```sh\nnode bench/script/convergence-time.js -h\n\n  Usage: convergence-time [options]\n\n  Options:\n\n    -h, --help                      output usage information\n    --cycles [value]                number of cycles\n    --workers [value]               number of workers\n    --codec [value]                 msgpack or json\n    --dissemination-factor [value]  dissemination factor\n    --interval [value]              interval\n    --join-timeout [value]          join timeout\n    --ping-timeout [value]          ping timeout\n    --ping-req-timeout [value]      ping req timeout\n    --ping-req-group-size [value]   ping req group size\n    --max-dgram-size [value]        max dgram size\n```\n```sh\nnode bench/script/convergence-time.js\n\nconfiguration:\n- cycles 10\n- workers 10\n- codec msgpack\n- dissemination factor 15\n- interval 20 ms\n- join timeout 100 ms\n- ping timeout 4 ms\n- ping req timeout 12 ms\n- ping req group size 3\n- max dgram size 512 bytes\nconvergence time under single node failure\nhistogram data:\n- count 10\n- min 76\n- max 123\n- mean 100\n- median 101\n- variance 308.44444444444446\n- std dev 17.56258649642599\n- p75 116.25\n- p95 123\n- p99 123\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrhooray%2Fswim-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrhooray%2Fswim-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrhooray%2Fswim-js/lists"}