什么是高并发性的良好骨骼配置

时间:2014-05-21 22:51:57

标签: mysql jdbc bonecp

我有一个必须处理高并发性的Web应用程序,比如100个用户查询相同的5个表(其中一个表,返回超过500行)以及其他一些用户同时插入这些表。

当用户太多时,并发性太高,我的应用程序挂起,我必须重启tomcat。我在日志中找不到多少。当我执行"显示进程列表时;"在MySQL中,每个连接都有进程,其中大多数都处于状态"查询" ...在应用程序挂起之前,一个进程一个进程,进入"睡眠"状态,直到所有进程都具有此状态并且应用程序挂起。

很难诊断正在发生的事情......我试图更好地同步代码,但没有任何成功......好吧,我在这里询问有关我是否有意见的意见。 m使用在这种环境中使用的良好骨骼配置:

<property name="bonecp.idleMaxAgeInMinutes">10</property>
            <property name="bonecp.maxConnectionAgeInSeconds">3000</property>   
            <property name="bonecp.idleConnectionTestPeriodInMinutes">5</property>
            <property name="bonecp.connectionTestStatement">/* ping */ SELECT 1</property>
            <property name="bonecp.partitionCount">2</property>
            <property name="bonecp.acquireIncrement">2</property>
            <property name="bonecp.maxConnectionsPerPartition">12</property>
            <property name="bonecp.minConnectionsPerPartition">5</property>
            <property name="bonecp.statementsCacheSize">50</property>
            <property name="bonecp.releaseHelperThreads">3</property>

根据我的MySQL配置,我使用默认设置,除了这两个:

autocommit = 0
innodb_thread_concurrency = 8 

(服务器有3个CPU和1个磁盘)

你们劝我改变什么吗?谢谢!

3 个答案:

答案 0 :(得分:8)

作为BoneCP的作者,我建议你看一下这个池: https://github.com/brettwooldridge/HikariCP

因为BoneCP现在既老又被HikariCP取代,它提供了卓越的性能。

答案 1 :(得分:3)

如果你使用HikariCP,我建议从默认值开始,看看它是如何工作的。我还建议您阅读维基中的MySQL configuration tips。如果您有任何疑问,我们的Google群组会得到更快的回复,但您当然也可以在这里免费提问(但我们会在此处查看较少)。

答案 2 :(得分:1)

在使用boneCP之前,您必须充分了解所有配置,例如下面的

  # Whether auto commit should be used
  autoCommit = true

  # If non null, the transaction isolation level to use.
  isolation = null

  # Whether the database should be treated as read only
  readOnly = false

  # Whether opened statements should be automatically closed
  closeOpenStatements = true

  # The pool partition count
  partitionCount = 1

  # The maximum number of connections per partition
  maxConnectionsPerPartition = 50

  # The minimum number of connections per partition
  minConnectionsPerPartition = 5

  # The increment to acquire connections in
  acquireIncrement = 1

  # The acquire retry attempts
  acquireRetryAttempts = 10

  # The delay to wait before retrying to acquire a connection
  acquireRetryDelay = 1 second

  # The connection timeout
  connectionTimeout = 1 second

  # The idle age to expire connections
  idleMaxAge = 10 minutes

  # The maximum a connection should live for
  maxConnectionAge = 1 hour

  # Whether JMX reporting should be disabled
  disableJMX = true

  # Whether statistics should be kept
  statisticsEnabled = false

  # How frequently idle connections should be tested
  idleConnectionTestPeriod = 1 minute

  # Disable connection tracking
  disableConnectionTracking = true

  # The time limit for executing queries. 0 means no time limit.
  queryExecuteTimeLimit = 0

  # Whether the connection should be reset when closed
  resetConnectionOnClose = false

  # Whether unresolved transations should be detected
  detectUnresolvedTransactions = false

  # An SQL statement to execute to test if a connection is ok after it is created.
  # Null turns this feature off.
  initSQL = null

  # An SQL statement to execute to test if a connection is ok before giving it out of the pool.
  # Null turns this feature off.
  connectionTestStatement = null

  # Whether SQL statements should be logged
  logStatements = true 

通过更改上面的参数来调整您的应用程序并选择最适合您的应用程序。上面的设置适用于我的应用程序[Java Play框架]