tendermint / js-abci

Javascript ABCI libraries
87 stars 41 forks source link

Message handler concurrency #16

Open mappum opened 6 years ago

mappum commented 6 years ago

Currently we pass messages to the app serially, blocking until the handler has returned a response. In the future, we will want to be able to handle messages concurrently, e.g. for processing checkTx requests in parallel for performance gains.

KrishnaPG commented 5 years ago

I have put a 10 second timer in checkTx (to simulate a database lookup / http call) as below:

  checkTx: (request) => {
    console.log("checkTx: ", request);
    return new Promise((resolve, reject) => {
      setTimeout(() => { console.log("resolving tx:", request); resolve({}); }, 10000);
    })
  }

Tendermint core started to error out on broadcastTxCommit:

Error on broadcastTxCommit   module=rpc err="Timed out waiting for tx to be included in a block"

When it is not erring out, It is still waiting for the 10 seconds to complete, before accept the next checkTx. So, if you have 10 users trying to call checkTx at the same time, and each one takes some time, then all the other will have to wait - the core is not accepting multiple checkTx calls simultaneously, it is waiting for the prior call to complete first.

Adding the ability to perform checkTx in parallel will remove that process bottleneck