The recent acceptance was finally completed, and it was just a little relieved. Previously, the system was positioned as distributed deployment, but it was changed to centralized deployment in the final launch phase, in this way, the performance problem becomes a tough issue. After the project goes online, the out-of-the-box memory overflow and database lock table problems frequently occur. In addition, the slow concurrency problem occurs during stress testing, after N
The recent acceptance was finally completed, and it was just a little relieved. Previously, the system was positioned as distributed deployment, but it was changed to centralized deployment in the final launch phase, in this way, the performance problem becomes a tough issue. After the project goes online, the out-of-the-box memory overflow and database lock table problems frequently occur. In addition, the slow concurrency problem occurs during stress testing, after a long time of suffering, we have finally achieved some results. Below is a simple record for your reference and communication. You are welcome to correct the flaws.
1. Minimize the size of the service transaction code block. When modifying A record in A transaction, the corresponding table will be locked. For example, transaction A modifies the records of table 1 and table 2, then, when transaction B modifies the records of table 1 and table 2, it will wait for transaction A to commit before obtaining the locks of Table 1 and Table 2. In this way, when the transaction is too long and the concurrency is large, the system will slow down.
2. Update operations on tables in transactions should be performed in a certain order. If the order is different, database table deadlocks may occur, for example: transaction A first modifies the two tables in the order of table1 and table2, while transaction B modifies the two tables in the order of table2 and table1. In this way, A deadlock occurs during concurrent execution.
3. Specify the transaction isolation level in the program. The default value is the database isolation level. mysql is a row-Level Lock, SQL server is a table-Level Lock, and SQL server needs to enable the snapshot mode if it is a SQL server.
Id= "TxAdvice">
TrIbutes>
TimeOut = "60000"/>
4. Enable the hibernate secondary cache (EHcache is recommended), which greatly improves the efficiency.
"Hibernate. cache. use_query_cache">
$ {Hibernate. cache. use_query_cache}
"Hibernate. cache. provider_class">
$ {Hibernate. cache. provider_class}
Hibernate. cache. use_query_cache = true
Hibernate. cache. provider_class = org. hibernate. cache. EhCacheProvider
Use getHibernateTemplate ().SetCacheQueries (true );
5. If there is a system with irregular memory overflow, consider whether the common module has the problem of traversing the set to query the database cyclically, after this situation is ruled out, the configuration can only be used up and down. Take jboss4.2.3 as an example.
Set JAVA_OPTS =-server? Xms512m-Xmx512m-XX: PeRmSize = 512 m-XX: MaxPermSize = 512 m-XX: + UseParallelGC-XX: + UseParallelOldGC
For detailed parameter descriptions, you can search for them on the Internet. Here, we need to point out that JVM has a maximum memory limit, on the Internet, this limit is generally 2 GB-3 GB (1.5 GB-2 GB in Windows and 2 GB-3 GB in Linux ), it is said that the 64-bit operating system does not have this restriction, but I have verified it on the 64-bit widows2008.
Program problems are often the main cause of memory overflow. You must pay attention to the quality of your code.
6. UseCluster, Web application server cluster (you can use apahce + modjk +McUse LVS + Keepaliv in at/jboss or linuxEd), If you use SQL server, you can use the cluster that comes with mysql 2008. If you are using mysql, we recommend that you use dual-host hot backup to enhance security.
FinalArchitecture: