zoukankan      html  css  js  c++  java
  • 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。

  • 相关阅读:
    随机图片
    单页网站
    最安全的聊天工具——Cryptocat
    一个游戏——小黑屋
    SAO Utils – SAO风格启动菜单
    对话框实现
    抖动文字
    Leetcode: 22. Generate Parentheses
    Leetcode: 21. Merge Two Sorted Lists
    Leetcode: 20. Valid Parentheses
  • 原文地址:https://www.cnblogs.com/getong/p/5161431.html
Copyright © 2011-2022 走看看