首页 > 代码库 > [Erlang危机](5.1.3)进程

[Erlang危机](5.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.

?全程追踪这个指标对诊断系统负载及检测进程泄漏都是非常有用的,当然也可以结合其它指标来一起诊断。

[Erlang危机](5.1.3)进程