Giter Site home page Giter Site logo

misterfixx / mojangpipe Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 0.0 92 KB

A java proxy server to Mojang's profile API, to avoid rate limits and serve profiles faster.

Java 100.00%
mojang-api java sparkjava okhttp3 squid-proxy caching caching-library proxy-server relay-server redis redis-cache redis-server

mojangpipe's Introduction

MojangPipe

MojangPipe is a proxy & relay server to Mojang's UUID -> Profile, Name -> UUID, UUID -> Name history APIs.

Motivation

As MCHeads keeps growing, the task of contacting Mojang's API locally gets more complicated, causing high database traffic and slow response times. MojangPipe solves these issues by acting as a middleman between MCHeads and Mojang while caching recent requests and using HTTP proxies when contacting Mojang's API to avoid various rate limits.

Solution

  • SparkJava Web app micro framework
  • Squid HTTP proxy server
  • OkHTTP 3
  • Redis
  • Order of operation per request:
    • Checking if there was already a failed attempt to serve this request within the last 4 hours - if there was, just return 204 status code with a blank body.
    • If there was not - checking if this request was already successfully served within the last 30 minutes - if it was, serve the cached version.
    • If not, use the current proxy in rotation to make the necessary API request.
    • Serve, cache the request and record statistics.

Squid

We use Squid as our HTTP proxy server, hosted locally on the same machine as the MojangPipe instance. Here is a quick guide on how to install Squid, and the config file we used for squid.

Proxy ports

Since Squid is configured to send requests through each one of its IPs depending on which port it was connected to, and squid is hosted locally on the same machine is the relay server, i didn't bother writing MojangPipe in a way that would let each server address in the proxies hash field to be customized, instead, it just stores the ports on which squid runs and selects a port based on the timestamp of the last time this proxy was in rotation.

Performance

Currently, in the production environment, this system has managed to reduce the rate of 429 status codes from 6% (of all outgoing requests to Mojang), to 0.5 - 0.02%.

Contributing

To contribute:

  1. Fork the project.
  2. Make a branch for each thing you want to do (don't put everything in your master branch: I don't want to cherry-pick and I may not want everything).
  3. Send a pull request.

mojangpipe's People

Contributors

misterfixx avatar trigary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.