Parity-ethereum: Parity can't handle too much RPC calls

Created on 22 Sep 2017  ·  8Comments  ·  Source: openethereum/parity-ethereum

Greetings.

Parity/v1.7.2-beta-9f47909-20170918/x86_64-linux-gnu/rustc1.19.0
Linux Debian Jessie.
Installed from dpkg binary.

Run with:
parity --no-ws --no-ui --tracing on --chain classic --base-path "/mnt/etc" --peers 50 --no-dapps

While scanning from 0 block to the current with trace_block, after 2-3k block i got this error and the clients crashing:

thread 'IO Worker #0' panicked at 'Can't create handshake: Auth', /checkout/src/libcore/result.rs:860
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>

I know this is a lot of RPC call pro second . I would like to catch every ether transfer to my db.

Update:
I use IPC to connect to the node.

Update 2:
When I put a 0.1 sec sleep between RPC calls then happens also..

F2-bug 🐞 M4-core ⛓ M6-rpcapi 📣 P5-sometimesoon 🌲

Most helpful comment

yeah, same issue happen when upgrade to v1.7.2

All 8 comments

yeah, same issue happen when upgrade to v1.7.2

Some report:
With version Parity/v1.7.6-stable-1953533-20171013/x86_64-linux-gnu/rustc1.20.0 the bug is still available.
Using web3.py with RPC and HTTP provider I get 20 request/s speed. With IPC more than 100 request/s but crashing.

Are you re-using the same IPC connection or spawning a new one for each request?

I think web3.py creates for every call new connection?!

You should get much better performance by re-using connections, I can easily do 20k req/s using rust-web3.

That said, we probably have a bug somewhere in IPC causing old connections to stay open. I think I saw another issue hanging around regarding this.

This is the simplest IPC requester in python:

import socket, json
from time import sleep

NODE_IPC_FILE = "/mnt/ssd1/etc/jsonrpc.ipc"

def make_request(id):
    request = json.dumps({"jsonrpc": "2.0", "params": [hex(id+1000), False], "method": "eth_getBlockByNumber", "id": id})
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock.connect(NODE_IPC_FILE)
    sock.settimeout(0.1)
    response = {}
    try:
        sock.sendall(request)
        raw_response = b""
        while True:
            try:
                raw_response += sock.recv(4096)
            except socket.timeout:
                sleep(0.01)
                continue
            if raw_response == b"":
                sleep(0.01)
            else:
                try:
                    response = json.loads(raw_response)
                except JSONDecodeError:
                    sleep(0.01)
                    continue
                else:
                    break
    finally:
        sock.close()
    return response

def test():
    for a in range(10000):
        try:
            make_request(a)
        except Exception as err:
            print a
            print err
            break

The result:

>>> test()
3894
[Errno 111] Connection refused

Parity:

2017-10-16 21:04:13  Imported #4661495 c781…b849 (1 txs, 0.03 Mgas, 1.64 ms, 0.64 KiB)
2017-10-16 21:04:28    10/50 peers    216 KiB chain    8 KiB db  0 bytes queue   21 KiB sync  RPC:  0 conn,  0 req/s, 31632 µs
2017-10-16 21:04:41  Imported #4661496 1eaf…6f0c (1 txs, 0.02 Mgas, 1.51 ms, 0.63 KiB)
thread 'IO Worker #2' panicked at 'Can't create handshake: Auth', /checkout/src/libcore/result.rs:860:4
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>

If I use:

def test():
    for a in range(10000):
        try:
            make_request(a)
            sleep(0.02)
        except Exception as err:
            print a
            print err
            break

Result:

>>> test()
771
[Errno 111] Connection refused

Something is wrong :(

This one? #6516

I have recoded the web3.py to let the IPC socket open, now works very well.

Was this page helpful?
0 / 5 - 0 ratings