WebSocket-bench分布式壓測部署

來源:互聯網
上載者:User

標籤:view   ssg   pen   mod   oba   秘鑰   logger   copy   邏輯   

1.首先要把使用者自己編寫業務壓測邏輯generator.js指令碼分別放到各壓測機上2.打通各壓測機的ssh登入秘鑰

這裡我請教同事得到一個比較快捷方便的配置方法----

採用centos系統內建的秘鑰-------->敲出ssh字元,然後雙按tab鍵,

就會出現我們想要的一些資料。。。。

然後執行ssh-copy-id   [email protected]地址

會出現一些選項,我們選擇yes,及root帳號輸入密碼就可以,

成功後,我們驗證一下,我們是否配合秘鑰成功  --------------我們這裡的控制台是要去連結多台壓載機,所以給其它壓載機的是公秘鑰,控制台是私秘鑰

直接敲入ssh  ip地址  查看是否登入成功

3 websocket-bench,控制指令碼編寫
#!/bin/bash#disabled selinuxnodes="172.18.10.38 172.18.10.37172.18.10.36172.18.10.35172.18.10.34172.18.10.33172.18.10.32172.18.10.31172.18.10.30172.18.10.49"for node in ${nodes}do               //---------這裡的大括弧是讓它並行運行命令,如果要串列去掉{}&{echo "online ${node} ..."ssh [email protected]${node} "cd /usr/lib/node_modules/websocket-bench/lib/ && websocket-bench -a 998 -c 2 -k -g generator.js http://172.18.10.10:3380"}&done
View Code4 各載入機generator.js指令碼
 1 /*global module, require*/ 2 var i =  0; 3 var m = 1; 4 var c = 0; 5 var logger = require(‘./logger‘); 6 var start = Date.now(); 7 setTimeout(function() { 8 }, 1000); 9 module.exports = {10   onConnect : function (client, done) {11 // 訂閱訊息12         var _m = m;13        client.emit(‘pusher_test:subscribe‘,{channel:‘private-group-NO‘ + _m, auth:‘callback‘});14         console.log(m);15 //  發送訊息16        setInterval(function() {17         if (i<1000000000){18          client.emit(‘pusher_test:messgae‘,{channel:‘private-group-NO‘ + _m, msg: ‘我是>第‘ + ++i +‘個訊息‘});19         }}, 1000);20 //  監聽訊息21         client.on(‘private-group-NO‘ + _m, function(content) {22                 console.log(new Date()+ new Date().getMilliseconds());23                  console.log(content);24          });25         c++;   //是判斷總訂閱人數26         if (c % 2 == 0) {27         m++;28         }29   done();30 }};
View Code

 

WebSocket-bench分布式壓測部署

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.