Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Parity can't handle too much RPC calls #6575

Closed
iFA88 opened this issue Sep 22, 2017 · 8 comments
Closed

Parity can't handle too much RPC calls #6575

iFA88 opened this issue Sep 22, 2017 · 8 comments
Labels
F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. P5-sometimesoon 🌲 Issue is worth doing soon.
Milestone

Comments

@iFA88
Copy link

iFA88 commented Sep 22, 2017

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..

@zhangsoledad
Copy link

zhangsoledad commented Sep 23, 2017

yeah, same issue happen when upgrade to v1.7.2

@5chdn 5chdn added F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. P5-sometimesoon 🌲 Issue is worth doing soon. labels Sep 27, 2017
@5chdn 5chdn added this to the 1.9 milestone Oct 5, 2017
@iFA88
Copy link
Author

iFA88 commented Oct 14, 2017

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.

@tomusdrw
Copy link
Collaborator

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

@iFA88
Copy link
Author

iFA88 commented Oct 16, 2017

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

@tomusdrw
Copy link
Collaborator

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.

@iFA88
Copy link
Author

iFA88 commented Oct 16, 2017

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 :(

@5chdn
Copy link
Contributor

5chdn commented Oct 18, 2017

This one? #6516

@iFA88
Copy link
Author

iFA88 commented Oct 18, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. P5-sometimesoon 🌲 Issue is worth doing soon.
Projects
None yet
Development

No branches or pull requests

4 participants