2016年8月25日 星期四

stress test, loda test, 壓力測試, node.js

常見的 stress test 工具為 java 的 JMeter, 但對 Nodejs server 做壓力測試可以用開源使用者開發的 library, 例如 loadtest 和 nodeload .


What is load-test, stress-test, and identity

Load testing is the process of putting demand on a software system or computing device and measuring its response.
Load testing is performed to determine a system's behavior under both normal and anticipated peak load conditions.
It helps to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing degradation.
When the load placed on the system is raised beyond normal usage patterns to test the system's response at unusually high or peak loads, it is known as stress testing.



Methodology 

There is little agreement on what the specific goals of load testing are. The term is often used synonymously with concurrency testing, software performance testing, reliability testing, and volume testing. Load testing is usually a type of non-functional testing, but it can be used as a functional test to validate suitability for use.


Nodejs VS Apache

http://zgadzaj.com/benchmarking-nodejs-basic-performance-tests-against-apache-php

nodeload

 is a collection of independent node.js modules for load testing HTTP services.
https://www.npmjs.com/package/nodeload


NODE STRESS SUITE

is a collection of independent node.js modules for load testing HTTP services.
https://github.com/Samuel29/NodeStressSuite

loadtest

Runs a load test on the selected HTTP or WebSockets URL. The API allows for easy integration in your own tests.
https://github.com/alexfernandez/loadtest




stress test, loda test, 壓力測試


What is load-test, stress-test, and identity

Load testing is the process of putting demand on a software system or computing device and measuring its response.
Load testing is performed to determine a system's behavior under both normal and anticipated peak load conditions.
It helps to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing degradation.
When the load placed on the system is raised beyond normal usage patterns to test the system's response at unusually high or peak loads, it is known as stress testing.



Methodology 

There is little agreement on what the specific goals of load testing are. The term is often used synonymously with concurrency testing, software performance testing, reliability testing, and volume testing. Load testing is usually a type of non-functional testing, but it can be used as a functional test to validate suitability for use.


nodeload

 is a collection of independent node.js modules for load testing HTTP services.
https://www.npmjs.com/package/nodeload


NODE STRESS SUITE

is a collection of independent node.js modules for load testing HTTP services.
https://github.com/Samuel29/NodeStressSuite

loadtest

Runs a load test on the selected HTTP or WebSockets URL. The API allows for easy integration in your own tests.
https://github.com/alexfernandez/loadtest




2016年8月24日 星期三

nodejs, express, middleware, use globally


Execute the CallBack function for every request (GET, POST). 

////////////////////////////////////////////////////
////////////////////////////////////////////////////

app.use(function (req, res, next) {
  console.log('Time:', Date.now( ));
});

//GET /api/v1/me/buildin
//Time: 1472093395081

////////////////////////////////////////////////////
////////////////////////////////////////////////////

2016年8月22日 星期一

shema design



RDBMS 

is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd.


Advantage of DocumentBD: 

左圖用了5個 Table 才能表達所需的資料結構, 右圖只需要 2 個Table 加上4個embed 的資料就能表達資料結構


設計時需要考慮到的因素:


  • 訪問模式決定了 schema 設計 (例如: Product -> Brand ; 同樣 Brand -> Product )
  • 數據庫讀寫操作的比例以及是否需要重點優化某一方的性能 (例如: 多數用戶先從 user 開始進行查詢)
  • 查詢和更新的操作類型
  • 數據生命周期和文檔的增長率


數據對像之間存在 3 種類型的關系


  • 1-1
  • 1-n
  • n-n


資料庫正規化











2016年8月19日 星期五

python, machine learning, quandl, tutorial

  • Tutorial from:

https://www.quandl.com/blog/api-for-global-stock-data


  • Register a account :




  • Look for the stock which you are interested, some of them is free and some not:

https://www.quandl.com/browse






  • Then get the Quandl Code, and paste it into the code:







2016年8月18日 星期四

set environment variable before npm start, nodejs

Set environment variable before npm start

 package.json

...
"scripts": {
  "start": "node app.js",
  "test": "CONFIG=abc mocha --reporter spec"
},
...



app.js

console.log(process.env.CONFIG)  //abc

2016年8月17日 星期三

ndoejs, function, object


  • Properties of an object are looked up from two places:
    1. the object itself (Obj.foo), and
    2. if the property does not exist, on the prototype of the object (Obj.prototype.foo).

  • New objects are created using a constructor, which is a regular function invoked using new

  • The new constructor call (e.g. new Foo()):
    1. creates a new object,
    2. sets the prototype of that object to Foo.prototype and
    3. passes that as this to the constructor.