pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

        <small id='IszjC'></small><noframes id='IszjC'>

        <i id='IszjC'><tr id='IszjC'><dt id='IszjC'><q id='IszjC'><span id='IszjC'><b id='IszjC'><form id='IszjC'><ins id='IszjC'></ins><ul id='IszjC'></ul><sub id='IszjC'></sub></form><legend id='IszjC'></legend><bdo id='IszjC'><pre id='IszjC'><center id='IszjC'></center></pre></bdo></b><th id='IszjC'></th></span></q></dt></tr></i><div class="wyu2ueq" id='IszjC'><tfoot id='IszjC'></tfoot><dl id='IszjC'><fieldset id='IszjC'></fieldset></dl></div>
        • <bdo id='IszjC'></bdo><ul id='IszjC'></ul>

      1. <legend id='IszjC'><style id='IszjC'><dir id='IszjC'><q id='IszjC'></q></dir></style></legend>
        <tfoot id='IszjC'></tfoot>

        使用 mysql 池對 node.js(集群)的性能進行基準測試

        Benchmarking Performance of node.js (cluster) with mysql pools : Lighttpd + PHP?(使用 mysql 池對 node.js(集群)的性能進行基準測試:Lighttpd + PHP?)
        <i id='zdcRd'><tr id='zdcRd'><dt id='zdcRd'><q id='zdcRd'><span id='zdcRd'><b id='zdcRd'><form id='zdcRd'><ins id='zdcRd'></ins><ul id='zdcRd'></ul><sub id='zdcRd'></sub></form><legend id='zdcRd'></legend><bdo id='zdcRd'><pre id='zdcRd'><center id='zdcRd'></center></pre></bdo></b><th id='zdcRd'></th></span></q></dt></tr></i><div class="mye220g" id='zdcRd'><tfoot id='zdcRd'></tfoot><dl id='zdcRd'><fieldset id='zdcRd'></fieldset></dl></div>
        <tfoot id='zdcRd'></tfoot>
          <tbody id='zdcRd'></tbody>

      2. <legend id='zdcRd'><style id='zdcRd'><dir id='zdcRd'><q id='zdcRd'></q></dir></style></legend>
          • <bdo id='zdcRd'></bdo><ul id='zdcRd'></ul>

            1. <small id='zdcRd'></small><noframes id='zdcRd'>

                • 本文介紹了使用 mysql 池對 node.js(集群)的性能進行基準測試:Lighttpd + PHP?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  Edit(2): 現在使用 db-mysql 和 generic-pool 模塊.錯誤率大幅下降,徘徊在 13%,但吞吐量仍然在 100 req/sec 左右.

                  Edit(1): 在有人建議 ORDER BY RAND() 會導致 MySQL 變慢后,我從查詢中刪除了該子句.Node.js 現在徘徊在 100 請求/秒左右,但服務器仍然報告連接錯誤:連接過多".

                  Node.js 或 Lighttpd 與 PHP?

                  您可能看到過許多 node.js 的Hello World"基準測試……但是hello world"測試,即使是每個請求延遲 2 秒的測試,甚至都沒有接近實際生產使用情況.我還使用 node.js 執行了Hello World"測試的這些變體,看到吞吐量約為 800 req/sec,錯誤率為 0.01%.但是,我決定進行一些更現實的測試.

                  也許我的測試不完整,很可能 node.js 或我的測試代碼真的有問題,所以如果你是 node.js 專家,請幫助我寫一些更好的測試.我的結果發表在下面.我使用 Apache JMeter 進行測試.

                  測試用例和系統規范

                  測試非常簡單.對用戶數的 mysql 查詢是隨機排序的.檢索并顯示第一個用戶的用戶名.mysql 數據庫連接是通過 unix 套接字連接的.操作系統是 FreeBSD 8+.8GB 內存.英特爾至強四核 2.x Ghz 處理器.在我遇到 node.js 之前,我稍微調整了 Lighttpd 配置.

                  Apache JMeter 設置

                  線程數(用戶):5000 我相信這是并發連接數

                  加速時間(以秒為單位):1

                  循環次數:10 這是每個用戶的請求數

                  Apache JMeter 最終結果

                  <前>標簽 |# 樣品 |平均 |敏|最大 |標準開發.|錯誤% |吞吐量 |KB/秒 |平均字節HTTP 請求 Lighttpd |49918 |2060ms |29 毫秒 |84790ms |5524 |19.47% |583.3/秒 |211.79 |371.8HTTP 請求 Node.js |13767 |106569ms |295ms |292311ms |91764 |78.86% |44.6/秒 |79.16 |1816

                  結果結論

                  Node.js 太糟糕了,我不得不提前停止測試.[已修復已完全測試]

                  Node.js 在服務器上報告連接錯誤:連接過多".[已修正]

                  大多數時候,Lighttpd 的吞吐量約為 1200 請求/秒.

                  然而,node.js 的吞吐量約為 29 req/sec.[已修復現在是 100req/sec]

                  這是我用于 node.js 的代碼(使用 MySQL 池)

                  var cluster = require('cluster'), http = require('http'), mysql = require('db-mysql'), generic_pool = require('generic-pool');var pool = generic_pool.Pool({名稱:'mysql',最大:10,創建:函數(回調){新的 mysql.Database({套接字:/tmp/mysql.sock",用戶:'根',密碼:'密碼',數據庫:'v3edb2011'}).connect(function(err, server) {回調(錯誤,這個);});},銷毀:函數(數據庫){db.disconnect();}});var server = http.createServer(function(request, response) {response.writeHead(200, {"Content-Type": "text/html"});pool.acquire(function(err, db) {如果(錯誤){return response.end("連接錯誤:" + err);}db.query('SELECT * FROM tb_users').execute(function(err, rows, columns) {pool.release(db);如果(錯誤){return response.end("查詢錯誤:" + err);}response.write(rows.length + ' ROWS found using node.js<br/>');response.end(rows[0]["username"]);});});});集群(服務器).set('工人', 5).聽(8080);

                  這是我用于 PHP (Lighttpd + FastCGI) 的代碼

                  query('SELECT * FROM tb_users ORDER BY RAND()');如果($結果){echo ($result->num_rows).'使用 Lighttpd + PHP (FastCGI) 找到的 ROWS<br/>';$row = $result->fetch_assoc();回聲 $row['用戶名'];} 別的 {echo '錯誤:數據庫查詢';}} 別的 {echo '錯誤:數據庫連接';}?>

                  解決方案

                  這是一個糟糕的基準比較.在 node.js 中,您選擇整個表并將其放入一個數組中.在 php 中,您只解析第一行.所以你的表越大,節點看起來就越慢.如果您讓 php 使用 mysqli_fetch_all,那將是類似的比較.雖然 db-mysql 應該很快,但它的功能不是很全,并且缺乏將其進行公平比較的能力.使用不同的 node.js 模塊,如 node-mysql-libmysqlclient 應該允許您只處理第一行.

                  Edit(2): Now using db-mysql with generic-pool module. The error rate has dropped significantly and hovers at 13% but the throughput is still around 100 req/sec.

                  Edit(1): After someone suggesting that ORDER BY RAND() would cause MySQL to be slow, I had removed that clause from the query. Node.js now hovers around 100 req/sec but still the server reports 'CONNECTION error: Too many connections'.

                  Node.js or Lighttpd with PHP?

                  You probably saw many "Hello World" benchmarking of node.js... but "hello world" tests, even those that were delayed by 2 seconds per request, are not even close to real world production usage. I also performed those variations of "Hello World" tests using node.js and saw throughput of about 800 req/sec with 0.01% error rate. However, I decided to some tests that were a bit more realistic.

                  Maybe my tests are not complete, most likely something is REALLY wrong about node.js or my test code and so if your a node.js expert, please do help me write some better tests. My results are published below. I used Apache JMeter to do the testing.

                  Test Case and System Specs

                  The test is pretty simple. A mysql query for number of users is ordered randomly. The first user's username is retrieved and displayed. The mysql database connection is through a unix socket. The OS is FreeBSD 8+. 8GB of RAM. Intel Xeon Quad Core 2.x Ghz processor. I tuned the Lighttpd configurations a bit before i even came across node.js.

                  Apache JMeter Settings

                  Number of threads (users) : 5000 I believe this is the number of concurrent connections

                  Ramp up period (in seconds) : 1

                  Loop Count : 10 This is the number of requests per user

                  Apache JMeter End Results

                  Label                  | # Samples | Average  | Min   | Max      | Std. Dev. | Error % | Throughput | KB/sec | Avg. Bytes
                  
                  HTTP Requests Lighttpd | 49918     | 2060ms   | 29ms  | 84790ms  | 5524      | 19.47%  | 583.3/sec  | 211.79 | 371.8
                  
                  HTTP Requests Node.js  | 13767     | 106569ms | 295ms | 292311ms | 91764     | 78.86%  | 44.6/sec   | 79.16  | 1816
                  

                  Result Conclusions

                  Node.js was so bad i had to stop the test early. [Fixed Tested completely]

                  Node.js reports "CONNECTION error: Too many connections" on the server. [Fixed]

                  Most of the time, Lighttpd had a throughput of about 1200 req/sec.

                  However, node.js had a throughput of about 29 req/sec. [Fixed Now at 100req/sec]

                  This is the code i used for node.js (Using MySQL pools)

                  var cluster = require('cluster'), http = require('http'), mysql = require('db-mysql'), generic_pool = require('generic-pool');
                  
                  var pool = generic_pool.Pool({
                      name: 'mysql',
                      max: 10,
                      create: function(callback) {
                          new mysql.Database({
                              socket: "/tmp/mysql.sock",
                              user: 'root',
                              password: 'password',
                              database: 'v3edb2011'
                          }).connect(function(err, server) {
                              callback(err, this);
                          });
                      },
                          destroy: function(db) {
                          db.disconnect();
                      }
                  });
                  
                  var server = http.createServer(function(request, response) {  
                      response.writeHead(200, {"Content-Type": "text/html"});  
                      pool.acquire(function(err, db) {
                          if (err) {
                              return response.end("CONNECTION error: " + err);
                          }
                  
                          db.query('SELECT * FROM tb_users').execute(function(err, rows, columns) {
                              pool.release(db);
                  
                              if (err) {
                                  return response.end("QUERY ERROR: " + err);
                              }
                              response.write(rows.length + ' ROWS found using node.js<br />');
                              response.end(rows[0]["username"]);
                          });
                      });   
                  });
                  
                  cluster(server)
                    .set('workers', 5)
                    .listen(8080);
                  

                  This this is the code i used for PHP (Lighttpd + FastCGI)

                  <?php
                    $conn = new mysqli('localhost', 'root', 'password', 'v3edb2011');
                    if($conn) {
                      $result = $conn->query('SELECT * FROM tb_users ORDER BY RAND()');
                      if($result) {
                        echo ($result->num_rows).' ROWS found using Lighttpd + PHP (FastCGI)<br />';
                        $row = $result->fetch_assoc();
                        echo $row['username'];
                      } else {
                        echo 'Error : DB Query';
                      }
                    } else {
                      echo 'Error : DB Connection';
                    }
                  ?>
                  

                  解決方案

                  This is a bad benchmark comparison. In node.js your selecting the whole table and putting it in an array. In php your only parsing the first row. So the bigger your table is the slower node will look. If you made php use mysqli_fetch_all it would be a similar comparison. While db-mysql is supposed to be fast it's not very full featured and lacks the ability to make this a fair comparison. Using a different node.js module like node-mysql-libmysqlclient should allow you to only process the first row.

                  這篇關于使用 mysql 池對 node.js(集群)的性能進行基準測試:Lighttpd + PHP?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                  <small id='r3tX7'></small><noframes id='r3tX7'>

                          <legend id='r3tX7'><style id='r3tX7'><dir id='r3tX7'><q id='r3tX7'></q></dir></style></legend>

                          <tfoot id='r3tX7'></tfoot>
                            <tbody id='r3tX7'></tbody>

                        • <i id='r3tX7'><tr id='r3tX7'><dt id='r3tX7'><q id='r3tX7'><span id='r3tX7'><b id='r3tX7'><form id='r3tX7'><ins id='r3tX7'></ins><ul id='r3tX7'></ul><sub id='r3tX7'></sub></form><legend id='r3tX7'></legend><bdo id='r3tX7'><pre id='r3tX7'><center id='r3tX7'></center></pre></bdo></b><th id='r3tX7'></th></span></q></dt></tr></i><div class="w2uymsk" id='r3tX7'><tfoot id='r3tX7'></tfoot><dl id='r3tX7'><fieldset id='r3tX7'></fieldset></dl></div>
                            <bdo id='r3tX7'></bdo><ul id='r3tX7'></ul>

                          • 主站蜘蛛池模板: 潜水搅拌机-双曲面搅拌机-潜水推进器|奥伯尔环保 | 胶辊硫化罐_胶鞋硫化罐_硫化罐厂家-山东鑫泰鑫智能装备有限公司 意大利Frascold/富士豪压缩机_富士豪半封闭压缩机_富士豪活塞压缩机_富士豪螺杆压缩机 | 东莞市天进机械有限公司-钉箱机-粘箱机-糊箱机-打钉机认准东莞天进机械-厂家直供更放心! | 巩义市科瑞仪器有限公司| 圆窗水平仪|伊莉莎冈特elesa+ganter | 真空泵厂家_真空泵机组_水环泵_旋片泵_罗茨泵_耐腐蚀防爆_中德制泵 | 空气能暖气片,暖气片厂家,山东暖气片,临沂暖气片-临沂永超暖通设备有限公司 | 隐形纱窗|防护纱窗|金刚网防盗纱窗|韦柏纱窗|上海青木装潢制品有限公司|纱窗国标起草单位 | 14米地磅厂家价价格,150吨地磅厂家价格-百科 | 海德莱电力(HYDELEY)-无功补偿元器件生产厂家-二十年专业从事电力电容器 | 硅胶管挤出机厂家_硅胶挤出机生产线_硅胶条挤出机_臣泽智能装备 贵州科比特-防雷公司厂家提供贵州防雷工程,防雷检测,防雷接地,防雷设备价格,防雷产品报价服务-贵州防雷检测公司 | 上海小程序开发-上海小程序制作公司-上海网站建设-公众号开发运营-软件外包公司-咏熠科技 | 北京普辉律师事务所官网_北京律师24小时免费咨询|法律咨询 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 右手官网|右手工业设计|外观设计公司|工业设计公司|产品创新设计|医疗产品结构设计|EMC产品结构设计 | 南京试剂|化学试剂|分析试剂|实验试剂|cas号查询-专业60年试剂销售企业 | 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | 点焊机-缝焊机-闪光对焊机-电阻焊设备生产厂家-上海骏腾发智能设备有限公司 | 搬运设备、起重设备、吊装设备—『龙海起重成套设备』 | 魔方网-培训咨询服务平台 | 空气能采暖,热泵烘干机,空气源热水机组|设备|厂家,东莞高温热泵_正旭新能源 | 杭州荣奥家具有限公司-浙江办公家具,杭州办公家具厂 | 天助网 - 中小企业全网推广平台_生态整合营销知名服务商_天助网采购优选 | 南京展台搭建-南京展会设计-南京展览设计公司-南京展厅展示设计-南京汇雅展览工程有限公司 | 行星搅拌机,双行星搅拌机,动力混合机,无锡米克斯行星搅拌机生产厂家 | 淄博不锈钢无缝管,淄博不锈钢管-鑫门物资有限公司 | 全自动在线分板机_铣刀式在线分板机_曲线分板机_PCB分板机-东莞市亿协自动化设备有限公司 | Brotu | 关注AI,Web3.0,VR/AR,GPT,元宇宙区块链数字产业 | VI设计-LOGO设计公司-品牌设计公司-包装设计公司-导视设计-杭州易象设计 | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | 臭氧实验装置_实验室臭氧发生器-北京同林臭氧装置网 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 紫外线老化试验箱_uv紫外线老化试验箱价格|型号|厂家-正航仪器设备 | 北京网站建设|北京网站开发|北京网站设计|高端做网站公司 | 河南砖机首页-全自动液压免烧砖机,小型砌块水泥砖机厂家[十年老厂] | 济南品牌包装设计公司_济南VI标志设计公司_山东锐尚文化传播 | 选宝石船-陆地水上开采「精选」色选机械设备-青州冠诚重工机械有限公司 | 水压力传感器_数字压力传感器|佛山一众传感仪器有限公司|首页 | 包塑丝_高铁绑丝_地暖绑丝_涂塑丝_塑料皮铁丝_河北创筹金属丝网制品有限公司 |