Workflow performance Optimization (Dare activiti scalability?) ) (1)

Source: Internet
Author: User
Tags visualvm

Workflow to do (home to-do list), load slowly, activiti this machine, see the code is all the data loaded into memory, and then code filtering, why do I say again?

Use VISUALVM to do performance test;

Previous colleague-given solution:

1. Put "Spring-instrument-3.2.1.release.jar" into Tomcat's lib directory;

2, Windows: Modify the Tomcat\bin\catalina.bat file, "set java_opts=%java_opts%%logging_manager%" after adding a line "set java_opts=%java_opts %-javaagent:%catalina_home%\lib\spring-instrument-3.2.1.release.jar ";

Linux: Modify the tomcat/bin/catalina.sh file, "# Uncomment the following line to make the umask available when using the" Add a row before "Java_op Ts=-javaagent: $CATALINA _home/lib/spring-instrument-3.2.1.release.jar ";

3, modify the Spring-context.xml file in the project, "<bean class=" Com.sinotaiyo.srpm.ApplicationContextUtil "/>" after adding a line "<context : Load-time-weaver weaver-class= "Org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> "," <property name= "DataSource" ref= "DataSource"/> "after adding a line" <property name= "Loadtimeweaver" ref= " Loadtimeweaver "/>";

Principle:

ASPECTJ provides two ways of slicing, the first through a special compiler, in the compilation period, the AspectJ language written in the class of the Java class, can be done through an ant or Maven task, the second way is the class loading period weaving, Also referred to as LTW (Load time Weaving).

Spring the loadtimeweaver-- a demand-led thinking

Try this configuration can start the project first;

First use the external Tomcat configuration to start the project to try;

Change, start error:

Severity: Exception sending context initialized event to listener instance of class Org.springframework.web.context.ContextLoad Erlistener

java.lang.IllegalStateException: Must start with the Java agent to use Instrumentationloadtimeweaver. See Spring documentation.

At Org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver.addTransformer ( instrumentationloadtimeweaver.java:87)

Modify the Tomcat configuration to use an external tomcat;

or not;

Linux under the can;

To modify the Tomat configuration:

Plus the boot VM parameter, it's ready;

Tomcat7-maven-plugin boot also joins the boot VM parameter to be able;

Install VISUALVM;

http://visualvm.java.net/download.html, download the multi-language pack version, decompression can be used;

VISUALVM Chinese online documentation;

Start, need jdk7;

Although Java_home has been installed on the machine, the configuration should be modified by itself; Search: Visualvm_jdkhome

"D:\J2EE\visualvm_138\etc\visualvm.conf"

Restore the original configuration, backup:

-javaagent:d:\j2ee\apache-tomcat-6.0.43\lib\spring-instrument-3.2.1.release.jar

Generate 100,000 data for testing:

First, find hibernate print SQL and additional parameters

There are 3 settings in Hibernate's profile hibernate.cfg.xml that are related to the display of SQL statements whose values are Boolean values:
1. Show_sql: Whether to display SQL statements
2, Format_sql: whether to format the output string, enhance the readability of SQL
3. Use_sql_comments: Whether a comment is displayed, indicating what operation produced the SQL statement.

If Show_sql=true is set, the default print-only SQL statement does not print parameters:

If you need to print the parameters, in the log4j configuration file: log4j.properties, add:

Log4j.logger.org.hibernate.type.descriptor.sql.basicbinder=trace

Log4j.loggerorg.hibernate.type.descriptor.sql.basicextractor=trace

If you need to view the values of named parameters in the query, continue to join:

Log4j.logger.org.hibernate.engine.queryparameters=debug

Log4j.logger.org.hibernate.engine.query.hqlqueryplan=debug

Next comes the full configuration:

Log4j.rootlogger=info, CA

# Consoleappender

Log4j.appender.ca=org.apache.log4j.consoleappender

Log4j.appender.ca.layout=org.apache.log4j.patternlayout

LOG4J.APPENDER.CA.LAYOUT.CONVERSIONPATTERN=%D{HH\:MM\:SS,SSS} [%t]%-5p%c%x-%m%n

# in order to display the parameters

Log4j.logger.org.hibernate.type.descriptor.sql.basicbinder=trace

Log4j.loggerorg.hibernate.type.descriptor.sql.basicextractor=trace

# to view the values of named parameters in a query

Log4j.logger.org.hibernate.engine.queryparameters=debug

Log4j.logger.org.hibernate.engine.query.hqlqueryplan=debug

You only need to set the Show_sql in Hibernate.cfg.xml to True and then copy the red code into the configuration file.

Just asked the workflow to go is MyBatis, not hibernate, OK;

Debug a bit and follow SQL;

or degree Niang good, search out;

Activiti Troubleshooting to-do list queries complex, API unfriendly design scenarios

Analysis of the above shortcomings and requirements, we believe that through the API approach to query, there are always a variety of defects, so put the target on the database, if you can define the way the view to solve the problem, it will completely solve the query convenience, flexibility, universality problems.

After analyzing Activiti's database tables, we found that the tables that were not complicated and were related to the backlog, including Act_ru_task, act_ru_identitylink,act_ru_task, stored the task-relevant information, act_ru_ The candidate group and candidate information is stored in the Identitylink, a more important question is, the candidate group in the Activiti, how the candidate is related to the user, organization, and role in the system, the solution provided in this article assumes that there is a system named Sys_role_ User table, which stores the roles and user correspondence, and the candidate groups and roles in Activiti are the same concept, what is specific in the developer's system and needs the developer extrapolate, this article only provides a design idea.

Find SQL difficult, from the page to find the new workflow where, find the corresponding code, write the program to generate it;

The original developer said in the load to do the code inside add a for loop, repeated loading to-do data, the scheme behind the test;

MD,JS compatibility issues;

Create a workflow The road is also very long;

The code is also encapsulated very well, 1:30 will not touch the mind, how to do?

Ativiti User manual;

Continue tomorrow;

Workflow performance Optimization (Dare activiti scalability?) ) (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.