Open Sourcing Steem Load Balancer and Introduce steem.justyy.com

in steem •  3 months ago 

Steem Load Balancer

Github: https://github.com/DoctorLai/steem-load-balancer/

Overview

The Steem Load Balancer is a Node.js-based application designed to distribute API requests across a list of predefined Steem API servers. It enhances application availability and reliability by routing requests to the most responsive node. This project is used by the STEEM Load Balancer RPC Node https://steem.justyy.com. A similar service, https://steem.senior.workers.dev/, is based on CloudFlare but comes with a daily quota of 100,000 requests.

image

Motivation

The primary motivation behind this project is to provide a scalable and reliable Load Balancer Node that can be integrated into applications to improve their availability and performance. Unlike CloudFlare-based solutions, this setup does not have a daily request quota, making it suitable for high-demand applications.

Features

  • Load Balancing: Distributes requests across multiple Steem API servers.
  • Rate Limiting: Protects against abuse by limiting the number of requests.
  • Logging: Provides detailed logs for debugging and monitoring.
  • SSL Support: Configurable SSL certificates for secure HTTPS communication.

Configuration

The configuration for the Steem Load Balancer is specified in the config.json file. Here's a breakdown of the configuration options:

Configuration File: config.json

{
    "nodes": [
        "https://api.steemit.com",
        "https://api.steememory.com",
        "https://api.worldofxpilar.com",
        "https://steemapi.boylikegirl.club",
        "https://api.justyy.com",
        "https://api.campingclub.me",
        "https://api.dlike.io",
        "https://api.pennsif.net",
        "https://api.worldofxpilar.com",
        "https://api.moecki.online"
    ],
    "rateLimit": {
        "windowMs": 60000,
        "maxRequests": 60
    },
    "version": "2024-09-14",
    "max_age": 3,
    "logging": true,
    "sslCertPath": "/root/.acme.sh/steem.justyy.com_ecc/fullchain.cer",
    "sslKeyPath": "/root/.acme.sh/steem.justyy.com_ecc/steem.justyy.com.key"
}

Configuration Options

  • nodes: An array of API server URLs to which requests will be distributed. You can add or remove nodes as needed.
  • rateLimit: Configuration for rate limiting.
  • windowMs: Time window in milliseconds for the rate limit (e.g., 60000 ms = 1 minute).
  • maxRequests: Maximum number of requests allowed in the time window.
  • version: The version of the Steem Load Balancer.
  • max_age: Cache duration for responses in seconds.
  • logging: Boolean value to enable or disable logging.
  • sslCertPath: Path to the SSL certificate file for HTTPS communication.
  • sslKeyPath: Path to the SSL key file for HTTPS communication.

Installation

Clone the Repository:

git clone https://github.com/doctorlai/steem-load-balancer.git
cd steem-load-balancer

Install Dependencies:

npm install

Configure

Update the config.json file with your desired nodes, rate limits, and SSL paths.

Build the Docker Image

DOCKER_IMAGE=steem-load-balancer
HOST_PORT=8080

# Build the Docker image
docker build -t $DOCKER_IMAGE .

Run the Server

docker run --name $DOCKER_IMAGE -p $HOST_PORT:8080 -v /root/.acme.sh/:/root/.acme.sh/ $DOCKER_IMAGE

image

./build-and-run.sh

Use the following utility to build the docker and then start the server.

./build-and-run.sh

SSL Configuration

If you have SSL certificates, provide the paths in the config.json file. If SSL is not configured or the certificate files are missing, the server will default to HTTP.

Rate Limiting

The rate limiting configuration prevents abuse by restricting the number of requests a user can make within a given time window. Adjust the rateLimit settings in config.json as needed.

Logging

Enable logging by setting "logging": true in config.json. Logs will be printed to the console and can help with debugging and monitoring.

Troubleshooting

Port 443 is already taken: Ensure no other process is using port 443. Use sudo lsof -i :443 to check. Change the port in the configuration if needed.

SSL Certificate Issues: Ensure the SSL certificate and key files are in the correct format and paths are correctly specified.

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!