All Projects → IBM → Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork

IBM / Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork

Licence: Apache-2.0 License
WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode.

Programming Languages

javascript
184084 projects - #8 most used programming language
go
31211 projects - #10 most used programming language
shell
77523 projects
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork

Build Blockchain Insurance App
Sample insurance application using Hyperledger Fabric
Stars: ✭ 609 (+2075%)
Mutual labels:  hyperledger-fabric, ibmcode
Decentralized Energy Composer
WARNING: This repository is no longer maintained ⚠️ We are no longer showing the Hyperledger Composer Service.
Stars: ✭ 129 (+360.71%)
Mutual labels:  hyperledger-fabric, ibmcode
Fabricnodesdk Starter
WARNING: This repository is no longer maintained ⚠️ > This repository will not be updated. The repository will be kept available in read-only mode.
Stars: ✭ 51 (+82.14%)
Mutual labels:  hyperledger-fabric, ibmcode
Blockchainnetwork Compositejourney
Part 1 in a series of patterns showing the building blocks of a Blockchain application
Stars: ✭ 217 (+675%)
Mutual labels:  hyperledger-fabric, ibmcode
Todo List Fabricv1
A todo list application using Hyperledger Fabric V1 as a data source
Stars: ✭ 103 (+267.86%)
Mutual labels:  hyperledger-fabric, ibmcode
BlockchainPublicRegulationFabric-Food
A Public Regulation Fabric example in the Food Industry
Stars: ✭ 47 (+67.86%)
Mutual labels:  hyperledger-fabric, ibmcode
mastering-blockchain
blockchain basis,logic,usage
Stars: ✭ 29 (+3.57%)
Mutual labels:  hyperledger-fabric
fabric-external-chaincodes
Hyperledger Fabric network in K8s with External Chaincodes as pods
Stars: ✭ 69 (+146.43%)
Mutual labels:  hyperledger-fabric
fabric-java-block
集成springboot和fabric sdk 提供rest api的接口
Stars: ✭ 37 (+32.14%)
Mutual labels:  hyperledger-fabric
hyperledger
区块链3.0 -> 超级账本hyperledger fabirc v1.1
Stars: ✭ 58 (+107.14%)
Mutual labels:  hyperledger-fabric
airmedfoundation-terminal
Airmed Foundation's IPFS + Hyperledger Fabric web client
Stars: ✭ 29 (+3.57%)
Mutual labels:  hyperledger-fabric
writing-chaincode
A repository to help experience developers with no Go or chaincode development experience to write and debug chaincodes.
Stars: ✭ 19 (-32.14%)
Mutual labels:  hyperledger-fabric
celery-connectors
Want to handle 100,000 messages in 90 seconds? Celery and Kombu are that awesome - Multiple publisher-subscriber demos for processing json or pickled messages from Redis, RabbitMQ or AWS SQS. Includes Kombu message processors using native Producer and Consumer classes as well as ConsumerProducerMixin workers for relay publish-hook or caching
Stars: ✭ 37 (+32.14%)
Mutual labels:  rabbitmq-cluster
gdpr-fingerprint-pii
Use Watson Natural Language Understanding and Watson Knowledge Studio to fingerprint personal data from unstructured documents
Stars: ✭ 49 (+75%)
Mutual labels:  ibmcode
turi-create-movie-recommender
Creating a movie recommendation system for iOS with Turi Create
Stars: ✭ 25 (-10.71%)
Mutual labels:  ibmcode
chiapos
Chia Proof of Space library
Stars: ✭ 265 (+846.43%)
Mutual labels:  blockchain-network
heroes-service-network
Short tutorial to build a blockchain network with Hyperledger Fabric
Stars: ✭ 22 (-21.43%)
Mutual labels:  hyperledger-fabric
bdk
Streamlined blockchain deployment kit for Hyperledger Fabric.
Stars: ✭ 43 (+53.57%)
Mutual labels:  hyperledger-fabric
global-citizen
WARNING: This repository is no longer maintained ⚠️ This repository, which contains assets to run a Hyperledger Composer application, is not being actively maintained due to a shift to focus on Hyperledger Fabric. This repository will not be updated. The repository will be kept available in read-only mode.
Stars: ✭ 54 (+92.86%)
Mutual labels:  ibmcode
EHR-on-blockchain
A Electronic Health Records system on hyperledger fabric maintained by consortium of hospitals for patients.
Stars: ✭ 35 (+25%)
Mutual labels:  hyperledger-fabric

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

Leveraging the Cache and Messaging Queue to Scale a Blockchain Network

Read this in other languages: 한국어.

In this step, we will configure Redis and RabbitMQ cluster in our architecture to control the flow of incoming request to blockchain network. 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 use RabbitMQ cluster with 3 nodes consisting of mirrored queues to queue the user requests and Redis cluster with 6 nodes (3 leaders and 3 followers) where results of execution are store for a short duration. In architecture diagram, we have RabbitMQ producer present in API containers that queue the requests to RabbitMQ cluster and RabbitMQ consumers 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.

You will find the configuration code for Redis in ./backend/utils/util.js.

You will find the configuration code for RabbitMQ in ./rabbitClient/utils/util.js

Included Components

  • Hyperledger Fabric
  • Docker
  • Hyperledger Fabric SDK for node.js

Application Workflow Diagram

Application Workflow

  1. Issue a git clone https://github.com/IBM/Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork.
  2. Issue the command build.sh to setup the network.

Prerequisites

Steps

  1. Run Build.sh Script to build and start the network
  2. Check the logs to see the results
  3. Test the Blockchain Network

1. Run the Build.sh Script

This accomplishes the following:

a. Clean up system by removing any existing blockchain docker images

b. Generate certificates

  • The crypto-config.yaml (Crypto configuration file) defines the identity of "who is who". It tells peers and orderers what organization they belown to and what domain they belong to.

c. Create Peers, Orderers and Channel

  • The configtx.yaml file initializes a blockchain network or channel and services with an Orderer Genesis Block which serves as the first block on a chain. Additionally, membership services are installed on each channel peer (in this case, the Shop and Fitcoin Peers).

d. Build docker images of the orderer, peers, channel, network

Open a new terminal and run the following command:

export FABRIC_CFG_PATH=$(pwd)
chmod +x cryptogen
chmod +x configtxgen
chmod +x generate-certs.sh
chmod +x generate-cfgtx.sh
chmod +x docker-images.sh
chmod +x build.sh
chmod +x clean.sh
./build.sh

2. Check the logs

Command

docker logs blockchain-setup

Output:

CA registration complete
CA registration complete
Default channel not found, attempting creation...
Successfully created a new default channel.
Joining peers to the default channel.
Chaincode is not installed, attempting installation...
Base container image present.
info: [packager/Golang.js]: packaging GOLANG from bcfit
info: [packager/Golang.js]: packaging GOLANG from bcfit
Successfully installed chaincode on the default channel.
Successfully instantiated chaincode on all peers.
Blockchain network setup complete.

Command

docker ps

Output:

f4ddfcb1e4d8        haproxy:1.7                                                                              "/docker-entrypoint.…"   5 minutes ago       Up 5 minutes        0.0.0.0:3000->3000/tcp                                rabbitclient
5f40495511f1        backend                                                                                  "node index.js"          5 minutes ago       Up 5 minutes                                                              fitcoin_fitcoin-backend_1
6ea304c78c40        backend                                                                                  "node index.js"          5 minutes ago       Up 5 minutes        0.0.0.0:3030->3030/tcp                                fitcoin_shop-backend_1
ef481c334532        rabbit-client                                                                            "node index.js"          5 minutes ago       Up 5 minutes        0.0.0.0:3003->3000/tcp                                rabbitclient3
51b7c6cee311        rabbit-client                                                                            "node index.js"          5 minutes ago       Up 5 minutes        0.0.0.0:3002->3000/tcp                                rabbitclient2
1195c7cb43ca        rabbit-client                                                                            "node index.js"          5 minutes ago       Up 5 minutes        0.0.0.0:3001->3000/tcp                                rabbitclient1
15533fe3a151        redis-server                                                                             "/docker-entrypoint.…"   5 minutes ago       Up 5 minutes        6379/tcp, 0.0.0.0:7000-7005->7000-7005/tcp            fitcoin_redis-server_1
556840abfc4d        dev-shop-peer-bcfit-1-0e0d4e71de9ac7df4d0d20dfcf583e3e63227edda600fe338485053387e09c50   "chaincode -peer.add…"   6 minutes ago       Up 6 minutes                                                              dev-shop-peer-bcfit-1
8c594ddc16f4        haproxy:1.7                                                                              "/docker-entrypoint.…"   6 minutes ago       Up 6 minutes        0.0.0.0:5672->5672/tcp, 0.0.0.0:15672->15672/tcp      rabbitmq
c59da84a4e7c        rabbitmq:3-management                                                                    "/usr/local/bin/clus…"   6 minutes ago       Up 6 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq2
f07024afd0f1        rabbitmq:3-management                                                                    "/usr/local/bin/clus…"   6 minutes ago       Up 6 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq3
7ef2085afd54        rabbitmq:3-management                                                                    "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq1
2a775a81c967        blockchain-setup                                                                         "node index.js"          7 minutes ago       Up 7 minutes        3000/tcp                                              blockchain-setup
90136f4c90fe        fitcoin-peer                                                                             "peer node start"        7 minutes ago       Up 7 minutes        0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp        fitcoin-peer
19e4890f71e3        shop-peer                                                                                "peer node start"        7 minutes ago       Up 7 minutes        0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp        shop-peer
654ada9fbbf6        ishangulhane/fabric-couchdb                                                              "tini -- /docker-ent…"   7 minutes ago       Up 7 minutes        4369/tcp, 9100/tcp, 0.0.0.0:9984->5984/tcp            shop-statedb
b19022ef3b2a        ishangulhane/fabric-couchdb                                                              "tini -- /docker-ent…"   7 minutes ago       Up 7 minutes        4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp            ca-datastore
6360ff012bbd        fitcoin-ca                                                                               "fabric-ca-server st…"   7 minutes ago       Up 7 minutes        0.0.0.0:8054->7054/tcp                                fitcoin-ca
9d06dd0a009d        orderer-peer                                                                             "orderer"                7 minutes ago       Up 7 minutes        0.0.0.0:7050->7050/tcp                                orderer0
0de13cd1ba31        shop-ca                                                                                  "fabric-ca-server st…"   7 minutes ago       Up 7 minutes        0.0.0.0:7054->7054/tcp                                shop-ca
9dba93e63b5c        ishangulhane/fabric-couchdb                                                              "tini -- /docker-ent…"   7 minutes ago       Up 7 minutes        4369/tcp, 9100/tcp, 0.0.0.0:8984->5984/tcp            fitcoin-statedb

Command

docker logs fitcoin_fitcoin-backend_1

Output:

CA registration complete
CA registration complete
CA registration complete
[x] Awaiting RPC requests on clientClient0
[x] Awaiting RPC requests on clientClient2
[x] Awaiting RPC requests on clientClient1

Command

docker logs fitcoin_shop-backend_1

Output:

CA registration complete
CA registration complete
Starting socker server
[x] Awaiting RPC requests on clientClient0

3. Test the BlockchainNetwork

In a separate terminal navigate to testApplication folder and run the following command:

npm install
node index.js

Navigate to url to view the blockchain blocks: http://localhost:8000/history.html

Blocks

Now navigate to url to perform operations on network : http://localhost:8000/test.html

Note : For this application the user queue value can be either : user_queue or seller_queue

Sample Enroll User request

Blocks

Sample Query request

Blocks

Sample Invoke request

Blocks

Additional Resources

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].