GithubHelp home page GithubHelp logo

matthewpattell / ijson Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lega911/ijson

0.0 1.0 0.0 2.14 MB

Inverted json

License: MIT License

Makefile 1.46% C++ 62.72% C 0.26% Dockerfile 0.38% Python 34.53% Shell 0.65%

ijson's Introduction

Inverted Json

Inverted Json is a job server which helps you to organize RPC, MQ, PubSub communication between clients and workers. It helps to save time and resources.

  • It's very fast, it's built with C/C++ and epoll, it's 7+ time faster than RabbitMQ for RPC (look at benchmark).
  • It's supported by all languages/frameworks, because it works via http.
  • It uses much less of memory (and CPU), less than 50+ time than RabbitMQ (memory usage).
  • Docker image is just 2.6Mb (slim version)
  • API is easy and compact (look at examples, quickstart will be soon)
  • It's a single point of access: [Client] -> [Inverted Json] <- [Worker] (clients and workers connect to Inverted Json), to simplify the configuration for projects.
  • Supported platforms: Linux, FreeBSD, MacOS, Docker.

Benchmark

Performance

Memory usage, CPU usage, Multi-core result

Try Inverted Json in 5 min

Example

Here we:
1. Start Inverted Json
2. A worker publishes a command
3. A client invokes the command
4. The worker responds to the client

read more, an article

Start ijson

docker run -it -p 8001:8001 lega911/ijson

Example with curl (client + worker)

# 1. a worker requests for a command (task) "test/command"
curl localhost:8001/test/command -H 'type: get'

# 2. a client invokes the command
curl localhost:8001/test/command -d '{"id": 123, "params": "test data"}'

# the worker receives {"id": 123, "params": "test data"}
# 3. and sends response with the same id
curl localhost:8001 -H 'type: result' -d '{"id": 123, "result": "data received"}'

# client receives {"id": 123, "result": "data received"}

Python client

response = requests.post('http://127.0.0.1:8001/test/command', json={'id': 1, 'params': 'Hello'})
print(response.json())

Python worker

while True:
    # get a request
    request = requests.post('http://127.0.0.1:8001/test/command', headers={'Type': 'get'}).json()
    
    # send a response
    response = {
        'id': request['id'],
        'result': request['params'] + ' world!'
    }
    requests.post('http://127.0.0.1:8001/', json=response, headers={'Type': 'result'})

ijson's People

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.