2014-05-21 41 views
4

我有一個Web應用程序,必須處理高併發性,就像100個用戶查詢相同的5個表(其中一個,返回500多行)和其他一些用戶插入在同一時間在這些表中。什麼將是一個很好的骨骼配置高併發

當用戶使用太多時,併發性太高,我的應用程序掛起,我必須重新啓動tomcat。我在日誌中找不到多少東西。當我執行「顯示進程列表」時在MySQL中,有針對每個連接的過程,其中大部分是與狀態「查詢」 ...應用程序掛起之前,一個過程一個,進入「睡眠」狀態,直到所有的過程有這樣的狀態和應用程序掛起。

這是非常難以診斷髮生了什麼......我想更好地同步的代碼,沒有任何成功...好,我在這裏要求的意見,如果我正在使用一個很好的bonecp在這樣的環境中使用的配置:

<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

如果使用HikariCP,我建議首先是默認值,看怎麼說你的作品。我也推薦閱讀wiki中的MySQL configuration tips。如果您有任何問題,我們的Google網上論壇可以獲得更快的回覆,但您當然也可以在此免費查詢(但我們不常在這裏查看)。

1

使用boneCP之前,必須通過改變上述PARAMS有像初級講座

# 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的遊戲框架]做工不錯

相關問題