couldn't connect to server

+3 votes
Hello

Here is my problem and would be great to hear any suggestion:

Background:

The MultiChain's version is the latest version.

Total two servers are Linux system. They are in the same LAN.

I created chain which named "chain1" and created stream which named "CQPBC-GZH" on server1.

I gave write/receive/send permissions of CQPBC-GZH to my server2 , then server2 subscribe stream CQPBC-GZH.

After that, I published data to stream CQPBC-GZH  from server2. Because I must publish 1,000,000 data to the stream, I writed a shell which created 100 threads to do that simultaneously.

Result:

All the 1,000,000 data used 10 hours to be published to stream CQPBC-GZH, only 27.7 per second.

And some errors occured during the Publish, which shown below:

1. error: no response from server , 50 times

2. error: couldn't connect to server, 638901 times

3. send successfully. 361049 times

 

The result is not good enough, I wonder why the publish rate is so slow and why so many errors happen.

Thx.
asked Jul 20, 2017 by Leon Wang

1 Answer

+2 votes
You definitely shouldn't use 100 simultaneous threads because MultiChain's API endpoints only run 4 threads (by default - this can be changed). In any event for optimal performance, use 2 threads, which should perform slightly better than 1.
answered Jul 21, 2017 by MultiChain
Thanks for response.
However, I used the same shell which created 100 simultaneous threads to past 10,000 data to stream CQPBC-GZH  from server2 yesterday. There are no failures, and publish rate is 107 per second.
Why is the result of 10,000 data so different from1,000,000 data ?
If 2 threads are perfect, why 100 simultaneous threads can work well when past 10,000 data?
Thx
What language and method are you using to call the API command to publish the data to the stream?
A shell in Linux.
#!/bin/bash
. ~/.bash_profile
tmpf=$0.fifo
mkfifo $tmpf
exec 10<>$tmpf
rm $tmpf
rm /home/ncbs/loan/mc.log

thread=50
total=1000000

{
  for(( i = 1; i <= ${thread} ; i++ ))
  do
     echo;
  done
}>&10

echo "Publish start..."

begin_time=$(date "+ %s")

for(( i = 0; i < ${total}; i++ ))
do
 read
 (multichain-cli chain1 publish CQPBC-GZH TS12345678 e9878de5ba86e5869ce59586e8a18c323031372d30372d31382d31303a30303a3030e6b89de58c97e694afe8a18ce785a7e6af8de5b1b1e58886e79086e5a4842d313030e585832d32303035e789882de58e8be58a9be6b58be8af95e695b0e68dae 1>>mc.log 2>>mc.log;echo >&10) &
done <&10

wait
end_time=$(date "+ %s")
cost_time=$(($end_time - begin_time))
echo "Finish! Publish $total items cost $cost_time seconds"
exec 10>&-
Thanks for posting that, it gives us a clearer idea of what you're doing. Our recommendation is not to use multichain-cli, but rather to access the API another way. Each time you run multichain-cli, a new Linux process is started, and this creates far more delay than the MultiChain API itself. If you want to benchmark the MultiChain API, we recommend using the ab (Apache benchmarking) tool instead. You can build your script around something like this:

echo '{"method":"publish","params":["CQPBC-GZH","TS12345678","e987"],"id":1}' > ./send-request.json
ab -n 1000000 -c 2 -A multichainrpc:[rpc-password] -p ./send-request.json 'http://127.0.0.1:[rpc-port]/'
Thanks for your reply. I used AB to benchmark the MultiChain API like what you show to me.  
echo '{"method":"publish","params":["CQPBC-GZH","TS12345678","e987"],"id":1}' > ./send-request.json
ab -n 1000000 -c 2 -A multichainrpc:[rpc-password] -p ./send-request.json 'http://127.0.0.1:[rpc-port]/'

I build 2 servers which named A and B for example, server A has AB, server B hasn't AB. I want to publish some items to stream on server B from server A, so I write send-request.json firstly, and then use AB command to send json to server B, However, The AB execute successfully, but the stream on server B not receive the items which send from server A, The count of StreamKeys and StreamKeyItems is not change also.
I don't know if there are something I forget? or something wrong? Why AB doesn't work ?
Thanks a lot.
First check the nodes on both servers are connected using getpeerinfo.

Second, subscribe to the stream on both nodes to see if the items are being added in either case.

Third, look at the output of ab to see if the requests are successful.
Can I send a JSONArray to multichain server? I want to execute many commands once.
Thanks a lot.
As far as I know you can only send hex data to the API. Therefore you need to stringify your JSON array to hex and then send it over.
...