Resulting transactions from multiple commands in a single submission

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?

1 Like

A single submission will always result in a single transaction.

And there are performance considerations. A single submission with 500 create commands will be much faster than 500 submissions with one create command each. Ledger round-trips including synchronisation and consensus are expensive.

1 Like

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?

1 Like

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.

1 Like

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:

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

  2. If your transaction gets large enough, eventually you will run into issues with the ledger time model and you have to increase the skew.

1 Like

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?

1 Like

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.

1 Like