rainshowerLabs / blutgang

the wd40 of ethereum load balancers
Other
343 stars 27 forks source link

Request timeout when using request batching #60

Open ishfx opened 8 months ago

ishfx commented 8 months ago

Describe the bug On a fresh install/run with the default config, I get the error Request timeout for all my requests to blutgang.

To Reproduce

{code:-32001, message:"error: Request timed out! Try again later..."}

- Find warning message in logs:

Info: Checking RPC health... OK! Info: Connection from: 127.0.0.1:55106 Info: Forwarding to: https://eth.merkle.io Wrn: An RPC request has timed out, picking new RPC and retrying. Info: Forwarding to: https://eth.merkle.io Wrn: An RPC request has timed out, picking new RPC and retrying. Info: Forwarding to: https://eth.merkle.io Wrn: An RPC request has timed out, picking new RPC and retrying. ... Info: Checking RPC health... OK!

{"jsonrpc":"2.0","id":1,"result":"0x1"}

Expected behavior blutgang shouldn't timeout since the rpc didn't return any error/timeout.

Specs:

ishfx commented 8 months ago

Alright, I missed the TTL config which was 30ms in the default config. I have to admit I wasn't expecting a TTL to be a request timeout. It's usually used for a lifespan (for example how much time to keep a data in a cache).

So after raising it to something like 5000ms, I don't hit the timeouts anymore.


Bu then I got another issue, still with the default config, only change is TTL set to 5000ms, butgang crashes after subscribing to newHeads without logging an error.

> docker run --rm -v $(realpath ./conf.toml):/app/config.toml --network host makemake1337/blutgang

Info: Using config file at config.toml
Sorting RPCs by latency...
https://eth.merkle.io: 129183072.13ns
Info: Starting Blutgang 0.3.0 Garreg Mach
Info: Bound to: 127.0.0.1:3000
Wrn: Reorg detected!
Removing stale entries from the cache.
Info: Adding user 1 to sink map
Info: Subscribe_user finding: ["newHeads"]

I tried with different RPC providers (free and paid). Every time the websocket transport is enabled, it crashes at startup.

Any ideas why ?

Thanks in advance!

makemake-kbo commented 8 months ago

@ishfx this is weird, does blutgang just hang at Info: Subscribe_user finding: ["newHeads"]? Could you try running blutgang with the debug-verbose feature flag (add -debug to your tag ie. 0.3.1-debug) and posting the output?

ishfx commented 8 months ago

Hey @makemake-kbo , thanks for the reply. Here are my test results:

Still default config with 5s TTL.

So 0.3.1 fixed something related to websockets, I saw a commit about that so maybe that was the issue.

I was using the latest docker version:

>docker run --rm -v $(realpath ./conf.toml):/app/config.toml --network host makemake1337/blutgang:latest ./blutgang --version

blutgang Blutgang 0.3.0 Garreg Mach

The 0.3.1 could be pushed to the docker repo I think.


But now I have another issue (with 0.3.1) :eyes: This time I have the full log.

The test:

Thanks !


More context about the error:

It just happens that I always batch my jsonrpc requests, this can be done by sending an array of jsonrpc calls. This is why blutgang couldn't parse the json correctly I guess.

To sum up:

{"jsonrpc":"2.0","id":1,"result":"0x126d0da"}


- Batch RPC call to `RPC`: OK
```sh
curl 'https://eth.merkle.io' \
  -X POST \
  -H 'Content-Type: application/json' \
  --data-raw '[{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber"}]'
[{"jsonrpc":"2.0","id":1,"result":"0x126d0e1"}]

So my understanding is that blutgang doesn't handle Batched rpc calls (which is just an array of rpc call, executed sequentially).

makemake-kbo commented 8 months ago

@ishfx latest docker container has been pushed, thanks!

blutgang doesnt do batched requests at all. this will be a thing once the request processing pipeline gets refactored in the next release. there is no eta because it will be a major rewrite and includes major restructuring of the db aswell.

there was another issue in the past related to batched request that was closed due to lack of activity. ill keep this one until batched requests get merged: https://github.com/rainshowerLabs/blutgang/issues/17

ishfx commented 8 months ago

@makemake-kbo Alright, fair enough! Thanks again for the work :smiley:

I'll go ahead and close this issue then.

A quick note about batches: This is crucial for performance, so I think it should become a priority after refacto as blutgang strives to be the best load balancer in terms of performance.


Oups sorry: I didn't catch that last part about keeping this issue open, reopened!

rarecrumb commented 8 months ago

Batching is something I'd love to see implemented.