Stress Test - Instructions

+1 vote
Hello! I was wondering if, perhaps, you would have a set of scripts or tools to help stress test your network after you adjusted certain parameters?

If that doesn't turn out to be possible, could you give a direction on what would you do (and use)/how would you architect such a test?

asked Feb 12, 2019 by tloriato

1 Answer

+1 vote
Best answer
Here's one of the (command line) PHP scripts we use for stress testing and benchmarking publishing items to streams. You'll need to adjust some constants at the top for your chain:


    define('CONST_MULTICHAIND_HOST', '');
    define('CONST_MULTICHAIND_PORT', '[enter rpc port]');
    define('CONST_MULTICHAIND_USER', 'multichainrpc');
    define('CONST_MULTICHAIND_PASS', '[enter password]');
    define('CONST_PUBLISH_FROM', '[enter address]');
    define('CONST_PUBLISH_STREAM', '[enter name of stream you created]');
    define('CONST_PUBLISH_TXS', 15625*4);
    define('CONST_PUBLISH_PER_TX', 32);
    define('CONST_PUBLISH_KEYS', 1000);
    define('CONST_PUBLISH_SIZE_MIN', 1);
    define('CONST_PUBLISH_SIZE_MAX', 32);
    define('CONST_PUBLISH_OFFCHAIN', false);
    for ($tx=1; $tx<=CONST_PUBLISH_TXS; $tx++) {

        for ($item=0; $item<CONST_PUBLISH_PER_TX; $item++) {
            $hexlength=2*mt_rand(CONST_PUBLISH_SIZE_MIN, CONST_PUBLISH_SIZE_MAX);

            for ($build=ceil($hexlength/4); $build--; $build>=0)
                $data.=str_pad(dechex(mt_rand(0, 65535)), 4, '0', STR_PAD_LEFT);

                'for' => CONST_PUBLISH_STREAM,
                'key' => str_pad(mt_rand(0, CONST_PUBLISH_KEYS-1), 9, '0', STR_PAD_LEFT),
                'data' => substr($data, 0, $hexlength),
                'options' => CONST_PUBLISH_OFFCHAIN ? 'offchain' : ''

        if ($valid) {
            printf("%9d tx / %9d items / %9.3f sec: %s (%6.1f items/sec)\n", $tx, $tx*CONST_PUBLISH_PER_TX,
                $elapsed, $txid, $tx*CONST_PUBLISH_PER_TX/$elapsed);
        } else {
    function curlless_json_rpc_send($host, $port, $user, $password, $method, $params=array())
        $strUserPass64= base64_encode($user.':'.$password);
            'id' => time(),
            'method' => $method,
            'params' => $params,

        $header=  'Content-Type: application/json'."\r\n".
                  'Content-Length: '.strlen($payload)."\r\n".
                  'Connection: close'."\r\n".
                  'Authorization: Basic '.$strUserPass64."\r\n";
        $options = array(
            'http' => array(
                'header'  => $header,
                'method'  => 'POST',
                'content' => $payload
        $context  = stream_context_create($options);
        $response = file_get_contents($url, false, $context);
        $result=json_decode($response, true);
        if (!is_array($result)) {
            $result=array('error' => array(
                'code' => 'HTTP 500',
                'message' => strip_tags($response).' '.$url

        return $result;       

    function get_microtime()
        return microtime(true);
answered Feb 12, 2019 by MultiChain
selected Feb 12, 2019 by tloriato
thanks! is this script used with a tool or as a stand-alone application with php?
This is a standalone PHP script.