Resulting transactions from multiple commands in a single submission
- georgOP 1
If I use the CommandSubmission service to submit multiple commands in the same submission, will this result in a single transaction with events from all commands, or will each command come back in its own transaction?
Related question: are there any performance considerations when deciding whether to submit multiple commands in one large transaction or separate them into smaller transactions?
- bernhard 1
A single submission will always result in a single transaction.
And there are performance considerations. A single submission with 500
createcommands will be much faster than 500 submissions with onecreatecommand each. Ledger round-trips including synchronisation and consensus are expensive. - georg 1
Thanks. What about putting all workload into a single command (and do the work in the choice), as opposed to splitting the workload across multiple commands (all within the same transaction)? Is there a (notable) overhead of processing multiple commands compared to a single, large one?
- bernhard 1
There shouldn’t be a difference in any real use case. Simply because in one case you transmit more data over the wire during submission while in the other you have a little more computation to do during interpretation, you could probably construct artificial scenarios in which there is a notable performance difference, though.
- cocreature 1
It’s worth pointing out that while a single transaction is indeed much faster there are two things to keep in mind before you start building up giant transactions for performance reasons:
-
Bundling things into a single transaction makes it easier to run int contention issues. As an extreme example consider multiple clients operating on contract keys where each operation only operates on a single contract key. If you submit them as individual transaction there is a good chance that the transactions don’t conflict. However, if you bundle all of them up into a single transaction the risk of conflicts between different clients increases.
-
If your transaction gets large enough, eventually you will run into issues with the ledger time model and you have to increase the skew.
-
- Gary_Verhaegen 1
Isn’t failure also at the entire transaction level? So if you submit 100 different operations in a single transaction, and #98 fails, the entire thing is rolled back?
- cocreature 1
Right, I was assuming that ignoring contention issues the individual operations are expected to succeed. If you cannot guarantee that then this is definitely an issue.