erlang驱动使用mysql-otp
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了erlang驱动使用mysql-otp相关的知识,希望对你有一定的参考价值。
Magnus Ahltorp的Mysql Driver里面介绍emysql的缺陷:
1. 隔离不够好,
2.不能伸缩
mysql-otp使用1个进程1个mysql连接,隔离得很好。推荐使用。
mysql-otp-poolboy 使用poolboy + erlang-otp 来形成线程池,使用poolboy来避免线程数量不足或者过多的情况。
参考:which erlang‘s pool is suitable?
poolboy automatically reduces workers when there is not work for them.
You get a worker to do some work with checkout from the pool, and you release the worker with checking, as an alternative, you enclose the work on transaction which automatically checkouts the worker and after its done it checkins the worker.
When you start the pool, poolboy automatically creates a number of size workers, waiting to handle some work.
When you call checkout, poolboy tries to get one of the workers which is already started, if all of the workers are already checkout because they are doing some work, it checks its max_overflow configuration and it starts to create workers to handle the load until it reaches max_overflow.
When a worker is released, if there are not more jobs for the workers, they are killed.
So if you create a pool like
{pool, [
{size, 100},
{max_overflow, 900}
]}
size表明最少进程池的数量,max_overflow表明如果进程池没有空闲进程,则最多新开多少个进程数量。
推荐使用mysql-otp-poolboy。
以上是关于erlang驱动使用mysql-otp的主要内容,如果未能解决你的问题,请参考以下文章
获取 badarith,[erlang,'+',[error,0],[],同时使用 Erlang 片段在 TSUNG 中执行算术运算