What are the Frequency Limits for Calls from chaincode to peer by invoking APIstub.PutState

45 Views Asked by At

I'm trying to test the performance of Hyperledger Fabric. I've made a simple chaincode like this

// calculate account balance...

start := time.Now()
// 2. put balance into ledger
err = putLatestState(APIstub, accountID, newBalance)
if err != nil {
    transactionLogger.Error(err.Error())
    return shim.Error(err.Error())
}
transactionLogger.Infof("putLatestState, after %d", time.Now().Sub(start))

// do something

my putLatestState() function

func putLatestState(APIstub shim.ChaincodeStubInterface, accountID string, newBalance string) error {
    key := accountID
    PutErr := APIstub.PutState(key, []byte(newBalance))
    if PutErr != nil {
        return errors.Errorf("Could not put balance for %s in the ledger: %s", accountID, PutErr.Error())
    }
    return nil
}

I want to note that I don't call any GetState to avoid read-write sets conflict.

When I call a single invoke (or concurrently about 100 requests at the same time), putLatestState costs only ~0.2ms (the logs below is in nanoseconds unit)

2020-12-08 19:33:20.463 +07 [main.transaction] credit -> INFO bfb putLatestState, after 156297
2020-12-08 19:33:20.466 +07 [main.transaction] credit -> INFO bfc putLatestState, after 171225
2020-12-08 19:33:20.470 +07 [main.transaction] credit -> INFO bfd putLatestState, after 164062
2020-12-08 19:33:20.474 +07 [main.transaction] credit -> INFO bfe putLatestState, after 163645
2020-12-08 19:33:20.478 +07 [main.transaction] credit -> INFO bff putLatestState, after 125038
2020-12-08 19:33:20.483 +07 [main.transaction] credit -> INFO c00 putLatestState, after 241095
2020-12-08 19:33:20.487 +07 [main.transaction] credit -> INFO c01 putLatestState, after 203689
2020-12-08 19:33:20.492 +07 [main.transaction] credit -> INFO c02 putLatestState, after 532434
2020-12-08 19:33:20.495 +07 [main.transaction] credit -> INFO c03 putLatestState, after 166303

but when I send many many requests, it costs a lot (3-9ms)

2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4efc putLatestState, after 9374660
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4efd putLatestState, after 9093387
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4efe putLatestState, after 9070922
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4eff putLatestState, after 9044761
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f00 putLatestState, after 8839449
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f01 putLatestState, after 8791697
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f02 putLatestState, after 8554055
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f03 putLatestState, after 8335684
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f04 putLatestState, after 8235291
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f05 putLatestState, after 8121222
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f06 putLatestState, after 7784521
2020-12-08 19:18:54.310 +07 [main.transaction] credit -> INFO 4f07 putLatestState, after 7640421
2020-12-08 19:18:54.311 +07 [main.transaction] credit -> INFO 4f08 putLatestState, after 7556968
2020-12-08 19:18:54.311 +07 [main.transaction] credit -> INFO 4f09 putLatestState, after 7392899
2020-12-08 19:18:54.311 +07 [main.transaction] credit -> INFO 4f0a putLatestState, after 7066036

I think that could be a limitation between chaincode and peer. Hope that someone can help me solve this

0

There are 0 best solutions below