Skip to content

Latest commit

 

History

History
69 lines (55 loc) · 2.43 KB

readme.md

File metadata and controls

69 lines (55 loc) · 2.43 KB

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'})