GithubHelp home page GithubHelp logo

notzree / wikigraph_server Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 11.56 MB

REST API to query / interact wikigraph pathfinder

Makefile 1.44% Go 97.51% Dockerfile 1.05%
golang microservice wikipedia-api wikipedia-search

wikigraph_server's Introduction

Wikigraph's server

About

Have you ever wanted to measure the arbitrary distance between 2 things? Do you want to become the best at Wikipedia Speedruns? Well look no further. Wikigraph is a pathfinder service that computes the number of links it takes to get from 1 Wikipedia article to another using a compressed binary graph (inspired by Tristan Hume)

This repo contains the code to run and deploy the Wikigraph Pathfinding microservice (which also contains a rate limiter microservice because I'm broke and aws is expensive). It exposes a rest api via the rate limiter, which communicates with the pathfinder service via gRPC + ProtoBuf. (Will prob containerize the gRPC apis and the rest api seperately)

I wrote the rate limiter myself and it's an implementation of the Token Bucket Algo using Redis. The Pathfinder currently runs a BFS implemented in Go and traverses the binary graph created in this repository. It's able to compute the shortest path between 2 wikipedia pages ~ 1 second with the database and everything running on my local machine. See the deployment section where I talk about real-world performance.

Using the API

//todo: add some docs

Deployment

I ran into multiple issues with excessive memory usage. My first initial prototype running the 2 gRPC services + the database was taking around 3.5-4 Gbs of ram. In an attmept to lower my costs, I moved the database onto supabase (excellent free tier) and then removed the gRPC service entirely and just utilized a rest api.

After lots of profiling + code optimizations, I lowered my memory usage from 3.5gbs to 1.4 gbs. Due to these cost-saving mechanisms, the actual latency of the API is around 2-4 seconds depending on the query.

wikigraph_server's People

Contributors

notzree avatar

Stargazers

 avatar

Watchers

 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.