Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
ljbennett62 edited this page Apr 12, 2018 · 7 revisions

Welcome to the controlling-flow-ofRequests-toBlockchain-using-Redis-and-RabbitMQ wiki!

Short Name

Leveraging Cache and Messaging Queue to scale Blockchain Network

Short Description

Control flow of requests to Blockchain network using RabbitMQ and Redis Cluster.

Offering Type

Emerging Tech - Blockchain

Introduction

Congrats! You have made it to the fourth in a series of patterns that teaches a developer how to get up and get going creating a Blockchain application using Fabric-Node-SDK. Now that you know how to create the network and define operations that can be done on the network you are ready to learn how to integrate RabbitMQ and Redis Custer to scale your Blockchain application. Let's get started with optimizing our blockchain application to handle a large number of requests.

Authors

By Ishan Gulhane

Code

https://github.com/IBM/controlling-flow-ofRequests-toBlockchain-using-Redis-and-RabbitMQ

Demo

N/A

Video

https://youtu.be/gdyQFXiAmRE

Overview

In this pattern, we will configure Redis and RabbitMQ cluster in our application architecture. With the direct use of REST API calls, it is not possible to control the number of requests sent to blockchain network, this might cause errors such as read/write conflicts etc. In order to control the flow of request sent to blockchain network and scale our application, we will do 2 things 1) use RabbitMQ cluster with 3 nodes consisting of mirrored queues to order the user requests and then 2) use Redis cluster with 6 nodes (3 master and 3 slaves) where results of execution are stored for a short duration. In the architecture diagram, we have the RabbitMQ producer present in API containers that queue the requests to the RabbitMQ cluster. The RabbitMQ consumers is also configured with an instance of Fabric-Node-SDK in Task execution containers to consume the requests from users and send it blockchain network for execution.

Flow

Architecture1

  1. Creating and Starting the Blockchain Application
  2. Performing transactions on Blockchain Network
  3. Viewing results and transaction blocks created in blockchain network

Included Components

Technology

Links

Blog Post

Imagine you have built a Blockchain application that you anticipate over 40K 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 over 40K attendees at a conference to want 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 that stood in front of them was “cash X amount of fitcoins” in for really 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 duration. This partnership of technologies is able to space out the requests over time; hence managing the load that the Blockchain application had to handle at any one time. Check out the 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.