{"id":21043081,"url":"https://github.com/mrinalxdev/mrinal-http2","last_synced_at":"2026-03-10T13:31:36.404Z","repository":{"id":255857511,"uuid":"851324129","full_name":"mrinalxdev/mrinal-http2","owner":"mrinalxdev","description":"An optimised solution for http2 and load balancer backend ","archived":false,"fork":false,"pushed_at":"2024-09-07T13:20:05.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T18:26:25.742Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/mrinalxdev.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":"2024-09-02T22:03:59.000Z","updated_at":"2024-11-13T04:21:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"02353cc1-4f83-4e2f-856f-cf0f9539407c","html_url":"https://github.com/mrinalxdev/mrinal-http2","commit_stats":null,"previous_names":["mrinalxdev/mrinal-http2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrinalxdev/mrinal-http2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fmrinal-http2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fmrinal-http2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fmrinal-http2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fmrinal-http2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrinalxdev","download_url":"https://codeload.github.com/mrinalxdev/mrinal-http2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2Fmrinal-http2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30334633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T12:41:07.687Z","status":"ssl_error","status_checked_at":"2026-03-10T12:41:06.728Z","response_time":106,"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":[],"created_at":"2024-11-19T14:10:52.198Z","updated_at":"2026-03-10T13:31:36.380Z","avatar_url":"https://github.com/mrinalxdev.png","language":"TypeScript","readme":"# HTTP/2 Server with Load Balancing\n\n## Table of Contents\n\n1. [Features](#features)\n2. [Installation](#installation)\n3. [Usage](#usage)\n4. [API Reference](#api-reference)\n5. [Configuration](#configuration)\n6. [Examples](#examples)\n7. [Contributing](#contributing)\n8. [License](#license)\n\n## Introduction\n\nThis project implements a high-performance HTTP/2 server with advanced load balancing capabilities using Node.js and TypeScript. It's designed to handle high-traffic scenarios, providing features like session management, rate limiting, and caching to ensure optimal performance and security.\nFeatures\n\nHTTP/2 support with secure HTTPS connections\nAdvanced load balancing with multiple algorithms:\n\n1. Round-robin\n2. Least connections\n3. Weighted round-robin\n4. IP hash\n5. Least response time\n6. Consistent hashing\n\n\nSession management\nRate limiting\nIn-memory caching\nCustom request handling\nHealth checks for backend servers\nMetrics collection and reporting\n\nProject Structure\nThe project consists of several TypeScript files, each responsible for a specific functionality:\n\nhttp2Server.ts: Main server implementation\nloadBalancer.ts: Load balancing logic\nsessionManager.ts: Session management\nrateLimiter.ts: Rate limiting implementation\ncaching.ts: In-memory caching\ntypes.ts: TypeScript interfaces and types\nexample-usage.ts: Example usage of the server\n\nPrerequisites\n\nNode.js (v14.x or later)\nTypeScript (v4.x or later)\nOpenSSL (for generating SSL certificates)\n\nInstallation\n\nClone the repository:\nCopygit clone https://github.com/yourusername/http2-load-balancer.git\ncd http2-load-balancer\n\nInstall dependencies:\nCopynpm install\n\nGenerate SSL certificates:\nCopyopenssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \\\n  -keyout server.key -out server.crt\n\n\nConfiguration\nThe server can be configured using various configuration objects:\n\nServerConfig: Main server configuration\nLoadBalancerConfig: Load balancer settings\nSessionConfig: Session management configuration\nRateLimitConfig: Rate limiting settings\nCacheConfig: Caching configuration\n\nRefer to the example-usage.ts file for configuration examples.\nUsage\n\nSet up your configuration in a new TypeScript file (e.g., app.ts).\nImport the necessary components and create an instance of HTTP2Server.\nAdd backend servers using the addBackend method.\nImplement your custom request handler using setRequestHandler.\nStart the server using the start method.\n\nExample:\ntypescriptCopyimport { HTTP2Server } from './http2Server';\n// ... import other necessary types and configurations\n\nconst server = new HTTP2Server(serverConfig, loadBalancerConfig, sessionConfig, rateLimitConfig, cacheConfig);\n\n// Add backends\nserver.addBackend({ url: 'https://api1.example.com', weight: 1, maxConnections: 100 });\nserver.addBackend({ url: 'https://api2.example.com', weight: 2, maxConnections: 200 });\n\n// Set custom request handler\nserver.setRequestHandler(async (stream, headers, payload) =\u003e {\n  // Implement your request handling logic here\n});\n\n// Start the server\nserver.start();\nRun your application:\nCopyts-node app.ts\nAPI Endpoints\nThe server doesn't have predefined endpoints. You need to implement your own endpoints in the custom request handler. The example-usage.ts file demonstrates how to create endpoints for:\n\n/api/users: A GET endpoint that returns a list of users (demonstrates caching)\n/api/login: A POST endpoint for user authentication (demonstrates session management)\n/api/protected: A GET endpoint that requires authentication (demonstrates using session data)\n\nAdvanced Features\nLoad Balancing\nThe load balancer supports multiple algorithms. You can choose the algorithm by setting the algorithm property in the LoadBalancerConfig:\n\n'round-robin': Distributes requests evenly across all backends\n'least-connections': Sends requests to the backend with the fewest active connections\n'weighted-round-robin': Like round-robin, but backends can handle more requests based on their weight\n'ip-hash': Consistently maps IP addresses to specific backends\n'least-response-time': Sends requests to the backend with the lowest average response time\n'consistent-hashing': Provides a consistent mapping of requests to backends, useful for caching scenarios\n\nSession Management\nThe SessionManager class handles creating, updating, and cleaning up sessions. Sessions are stored in-memory and can be accessed in your request handler.\nRate Limiting\nThe RateLimiter class provides basic IP-based rate limiting. You can configure the time window and maximum number of requests allowed per IP address.\nCaching\nThe CacheManager class provides in-memory caching of responses. You can configure which responses should be cached in your custom request handler.\nMonitoring and Metrics\nThe server provides basic metrics through the getMetrics method. You can periodically call this method to log or expose metrics about your server's performance.\nSecurity Considerations\n\nAlways use HTTPS in production environments.\nKeep your SSL certificates secure and up-to-date.\nImplement proper authentication and authorization in your application logic.\nRegularly update dependencies to patch any security vulnerabilities.\nConsider implementing additional security headers (e.g., HSTS, CSP) in your responses.\n\nFuture Enhancements\n\nImplement WebSocket support\nAdd support for external caching systems (e.g., Redis)\nImplement circuit breaker pattern for better fault tolerance\nAdd support for dynamic backend configuration updates\nImplement more comprehensive logging and tracing\n\nContributing\nContributions are welcome! Please feel free to submit a Pull Request.\nLicense\nThis project is licensed under the MIT License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fmrinal-http2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrinalxdev%2Fmrinal-http2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fmrinal-http2/lists"}