You will keep getting the same error even with lower TPS, until you change the approach. Just use a queue and operation grouping. 500 channel accounts are capable to deliver ~1000 operations per second (50 tx per ledger, 100 operations each).
Queue
Setup a queue for your operations. In the simplest form, it's an array, used as a buffer layer for transactions. Many languages (C#, Java, even JavaScript) provide a ready-to-use Queue
class implementation, it's one of the basic programming primitives. JavaScript allows to implement a queue as an Array
, methods .push()
and .shift()
allow to add an element and retrieve it accordingly.
When you want to initiate a Stellar transaction, you put it into the queue. Do not start building a transaction too early, operate with Operation
class on this stage.
There are a lot of enterprise grade messaging queue implementations that provide high throughput and may ensure delivery even in case of power failure. Take a a look at RabbitMQ or Kafka.
Batching
Once one of your channel accounts is available (transaction submitted successfully, or maybe it was in the idle state), you start building a transaction.
Mark the account as busy
, fetch the sequence, and create a new tx. Then take 100 oldest entries from the queue and add them to the tx. Sign the tx with all required signatures and submit it to the network. Once the confirmation from the Network is received, mark the channel account as idle
, now it's ready to process the next batch.