[Erlang危機](5.1.3)進程,erlang5.1.3
原創文章,轉載請註明出處:伺服器非業餘研究http://blog.csdn.net/erlib 作者Sunface聯絡郵箱:cto@188.com
Processes
Trying to get a global view of processes is helpful when trying to assess how much work is being done in the VM in terms of tasks. A general good practice in Erlang is to use processes for truly concurrent activities — on web servers, you will usually get one process per request or connection, and on stateful systems, you may add one process per-user — and therefore the number of processes on a node can be used as a metric for load.
Most tools mentioned in section 5.1 will track them in one way or another, but if the process count needs to be done manually, calling the following expression is enough:
查看全域進程數對瞭解VM的工作及負載情況是非常有協助的。一個良好的Erlang實踐就是為每一個並發的活動都派生出一個進程來處理——對於web伺服器,你經常會為每一個請求或串連建立一個進程,並且,在有狀態系統中,你可能會為每一個使用者都建立一個進程來進行管理,因此可以把節點上的總進程數做為負載情況的其中一個指標。
章節5.1中提到的大部分工具都能以各種的方式來追蹤它們,但如果手動擷取系統進程數目,你只需要使用下面這個函數就足夠了:
--------------------------------------------
1> length(processes()).
56535
-------------------------------------------
Tracking this value over time can be extremely helpful to try and characterize load or detect process leaks, along with other metrics you may have around.
全程追蹤這個指標對診斷系統負載及檢測進程泄漏都是非常有用的,當然也可以結合其它指標來一起診斷。