{"id":18914747,"url":"https://github.com/lau1944/load-balancer-in-java","last_synced_at":"2026-02-12T16:05:53.784Z","repository":{"id":60815202,"uuid":"544168303","full_name":"lau1944/Load-balancer-in-java","owner":"lau1944","description":"Implementation of popular load balancing algorithms in Java","archived":false,"fork":false,"pushed_at":"2022-10-05T02:55:54.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T21:46:23.466Z","etag":null,"topics":["algorithms","hash","java","load-balancer","server"],"latest_commit_sha":null,"homepage":"","language":"Java","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/lau1944.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}},"created_at":"2022-10-01T20:31:04.000Z","updated_at":"2022-10-03T02:11:39.000Z","dependencies_parsed_at":"2022-10-05T06:31:17.290Z","dependency_job_id":null,"html_url":"https://github.com/lau1944/Load-balancer-in-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lau1944/Load-balancer-in-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FLoad-balancer-in-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FLoad-balancer-in-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FLoad-balancer-in-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FLoad-balancer-in-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lau1944","download_url":"https://codeload.github.com/lau1944/Load-balancer-in-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lau1944%2FLoad-balancer-in-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29371510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["algorithms","hash","java","load-balancer","server"],"created_at":"2024-11-08T10:12:40.889Z","updated_at":"2026-02-12T16:05:53.770Z","avatar_url":"https://github.com/lau1944.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Load balancer in Java\n\nThis repo is a simple approach to achieve load balancing technique in Java.\n\n## Reference\n\n[Consistent Hash](#consistent-hashing)\n\n[Round robins](#round-robin)\n\n### Consistent Hashing\n\n[navigation](./consistent_hash/src/com/vau/consistent_hash)\n\n[wiki reference](https://en.wikipedia.org/wiki/Consistent_hashing)\n\nHow to run\n\n`Type the command inside the test folder`\n\n```shell\njava -cp ../outputs LoadBalancer.java\n ```\n\n```java\npublic final class LoadBalancer {\n    public static final void main(String[] args) {\n        List\u003cINode\u003e nodes = List.of(new INode[]{\n            new Node(\"127.0.0.1\", \"80\"), new Node(\"127.0.0.2\", \"80\"),\n                new Node(\"127.0.0.3\", \"80\"), new Node(\"127.0.0.4\", \"80\")\n\n        });\n        RouteTable table = new RouteTable(nodes);\n\n        // get random server\n        for (int i = 1; i \u003c 10; ++i) {\n            System.out.println(\"Server \" + i + \" : \" + table.getNode(\"192.1.4.\" + i).getIp());\n        }\n    }\n}\n```\n\n```output\nServer 1 : 127.0.0.4\nServer 2 : 127.0.0.1\nServer 3 : 127.0.0.4\nServer 4 : 127.0.0.1\nServer 5 : 127.0.0.1\nServer 6 : 127.0.0.1\nServer 7 : 127.0.0.4\nServer 8 : 127.0.0.1\nServer 9 : 127.0.0.1\n ```\n\n### Round robin \n\n[navigation](./round_robin/src/com/vau/round_robin)\n\n[wiki reference](https://www.nginx.com/resources/glossary/round-robin-load-balancing/#:~:text=What%20Is%20Round%2DRobin%20Load,to%20each%20server%20in%20turn.)\n\nHow to run\n\n`Type the command inside the test folder`\n\n```shell\njava -cp ../outputs LoadBalancer.java\n ```\n\n```java\npublic final class LoadBalancer {\n    public static void main(String[] args) {\n        List\u003cINode\u003e nodes = Arrays.asList(new ServerNode(\"127.0.0.1\", \"80\"), new ServerNode(\"127.0.0.2\", \"80\"),\n                new ServerNode(\"127.0.0.3\", \"80\"), new ServerNode(\"127.0.0.4\", \"80\"));\n        RoundRobin roundRobin = new RoundRobin(0, nodes);\n        ExecutorService executorService = Executors.newFixedThreadPool(20);\n        for (int i = 0; i \u003c 12; ++i) {\n            executorService.submit(new Request(roundRobin, i));\n        }\n        executorService.shutdown();\n    }\n\n    static class Request implements Runnable {\n        private RoundRobin robin;\n        private int index;\n\n        public Request(RoundRobin robin, int index) {\n            this.robin = robin;\n            this.index = index;\n        }\n\n        @Override\n        public void run() {\n            System.out.println(\"Server \" + index + \" now is: \" + robin.getServer().getIp());\n        }\n    }\n}\n```\n\n```output\nServer 4 now is: 127.0.0.1\nServer 9 now is: 127.0.0.2\nServer 8 now is: 127.0.0.1\nServer 2 now is: 127.0.0.3\nServer 5 now is: 127.0.0.2\nServer 3 now is: 127.0.0.4\nServer 7 now is: 127.0.0.4\nServer 0 now is: 127.0.0.1\nServer 6 now is: 127.0.0.3\nServer 10 now is: 127.0.0.3\nServer 11 now is: 127.0.0.4\nServer 1 now is: 127.0.0.2\n\n ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flau1944%2Fload-balancer-in-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flau1944%2Fload-balancer-in-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flau1944%2Fload-balancer-in-java/lists"}