Imagine you have built a blockchain application that you anticipate more than 40,000 people will use. Naturally, you will think about performance testing (stay tuned on that topic for the next pattern in this composite series). But even better: What can you do to proactively scale and successfully accommodate these large numbers of expected transactions? Let’s think about the bottleneck considerations.
Take a real use case that occurred recently with an application called The Secret Map. In this scenario, there was the potential for upwards of 40,000 attendees at a conference to sign up for an IoS application that would track their steps at the conference and issue a “fitcoin” after every 100 steps. The carrot in front of them was “cash X amount of fitcoins” in for cool prizes, such as a bandana and long-sleeve conference t-shirts. This was all managed on the blockchain network! Who wouldn’t jump at that? Well, we had to think quickly – how could we control the speed of large numbers of transaction request blocks being written on the blockchain network? Lightbulb time!
Let’s take a look at Redis and RabbitMQ. Redis is an open source in-memory data structure store, used as a database, cache, and message broker. It supports data structures such as strings, hashes, and lists. RabbitMQ is a lightweight open source message broker. Using these two tools helped to scale your blockchain application. RabbitMQ controls the input by ordering user requests, while Redis controls the output by holding blockchain transaction results, storing them for a short time. This partnership of technologies is able to space out the requests over time, managing the load that the blockchain application had to handle at any one time.
Check out the “Integrate RabbitMQ and Redis Cluster with a blockchain network” pattern to see the code that implements this use case. It may help you manage your next blockchain application that requires supporting thousands or even millions of transactions.