Identify Performance Bottlenecks using Application Performance Management (APM)

Identify Performance Bottlenecks using Performance Analyzer

识别性能瓶颈

ระบุคอขวดของประสิทธิภาพ


The saying from renowned computer scientist Donald Knuth goes:

着名的计算机科学家唐纳德·克努特(Donald Knuth)说:

คำพูดจากนักวิทยาศาสตร์คอมพิวเตอร์ชื่อดัง Donald Knuth ไปที่:


“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.”

Before wasting any effort on optimization, it is important to identify where the specific problems or inefficiencies are first.

在浪费任何优化的努力之前,重要的是要确定具体的问题或低效率是第一位的。

ก่อนที่จะเสียความพยายามในการปรับประสิทธิภาพให้เหมาะสม สิ่งสำคัญที่จะต้องพิจารณาว่าเป็นปัญหาเฉพาะหรือความไร้ประสิทธิภาพมาก่อน


  1. Identify elements in your userview pages and menu that require significant amounts of SQL or BeanShell scripts. These are the common causes of performance issues.

    确定需要大量SQL或BeanShell脚本的用户视图页面和菜单中的元素。这是性能问题的常见原因。

    ระบุองค์ประกอบในหน้ามุมมองและเมนูของผู้ใช้ที่ต้องการสคริปต์ SQL หรือ BeanShell จำนวนมาก นี่เป็นสาเหตุทั่วไปของปัญหาประสิทธิภาพการทำงาน

  2. Use the Performance Analyzer to help identify the slow elements in your app

    使用性能分析器  来帮助识别应用程序中的慢速元素

    ใช้ Performance Analyzer เพื่อช่วยระบุองค์ประกอบที่ช้าในแอปพลิเคชันของคุณ

  3. Identify slow SQL queries in your app by leveraging on your database e.g. for MySQL you can use the Slow Query Log 

    利用您的数据库识别您的应用程序中的慢SQL查询,例如对于MySQL,您可以使用慢查询日志 

    ใช้ฐานข้อมูลของคุณเพื่อระบุคิวรี SQL ที่ช้าในแอปพลิเคชันของคุณเช่น MySQL คุณสามารถใช้ Slow Query Log 

  4. Check your custom plugins to ensure that they do not introduce slow processing, database queries, etc.

    检查您的自定义插件,以确保它们不会引入缓慢的处理,数据库查询等

    ตรวจสอบปลั๊กอินที่กำหนดเองของคุณเพื่อให้แน่ใจว่าพวกเขาจะไม่ประมวลผลช้าแนะนำแบบสอบถามฐานข้อมูล ฯลฯ

  5. Identify whether there are sufficient resources (physical memory, storage space, Java VM allocation, etc) to handle your app usage, and whether there are any resource leakages.

    确定是否有足够的资源(物理内存,存储空间,Java VM分配等)来处理您的应用程序使用情况,以及是否有任何资源泄漏。

    ตรวจสอบว่าคุณมีทรัพยากรเพียงพอ (หน่วยความ, พื้นที่จัดเก็บ, Java VM ฯลฯ ) เพื่อจัดการการใช้งานแอปพลิเคชันของคุณและมีทรัพยากรรั่วไหลหรือไม่


Once you have identified where the potential problems are, you can then start to look into optimizing each of the areas, described in the following sections.

一旦确定了潜在问题的位置,就可以开始考虑优化每个区域,如下所述。



 

Ensure Sufficient Java VM Memory Allocation

确保足够的Java VM内存分配


The platform runs on the Java VM (JVM), and depending on the size and complexity of your apps and usage, you might need to tune the JVM heap memory size to suit your environment. If the setting is too low, the system will run out of memory resulting in OutOfMemory errors. However if the setting is too high compared the amount of physical RAM available, there might be quite a lot of swapping, in addition to overheads in garbage collection.

该平台运行在Java VM(JVM)上,根据应用程序的大小和复杂性以及使用情况,您可能需要调整JVM堆内存大小以适合您的环境。如果设置太低,则系统将耗尽内存,导致OutOfMemory错误。但是,如果该设置与可用物理RAM的数量相比太高,则除了垃圾收集的开销之外,还可能会有相当多的交换。


The default JVM settings are quite low to support installation on a user’s individual computer for testing or development. To get an optimum setting might require a bit of trial and error sometimes, depending on the usage environment.

默认的JVM设置非常低,以支持在用户的个人计算机上进行测试或开发的安装。要获得最佳设置,有时可能需要一些试用和错误,具体取决于使用环境。


You can use tools like VisualVM to monitor the memory usage as per Monitoring using VisualVM.

Some additional details are available at Deployment Best Practices#JavaVMConfiguration.

您可以使用工具,如VisualVM的监视内存的使用情况按  使用VisualVM的监视

 部署最佳实践#JavaVMConfiguration提供了一些额外的细节  。

คุณสามารถใช้เครื่องมือเช่น VisualVM เพื่อตรวจสอบการใช้หน่วยความจำ Monitoring using VisualVM แนวทางปฏิบัติที่ดีที่สุดในการปรับใช้รายละเอียดเพิ่มเติมบางอย่างสามารถดูได้ที่ Deployment Best Practices#JavaVMConfiguration.


 



Eliminate Resource Leakage (Memory, Database Connections, Files, Network, etc)

消除资源泄漏(内存,数据库连接,文件,网络等)

กำจัดการรั่วไหลของทรัพยากร (หน่วยความจำ, การเชื่อมต่อฐานข้อมูล, ไฟล์, เครือข่าย ฯลฯ )


At the platform level, Joget Workflow has been optimized and tested to ensure that there are no resource leakages.

在平台层面,Joget Workflow已经过优化和测试,以确保没有资源泄漏。

ในระดับแพลตฟอร์ม Joget Workflow ได้รับการปรับปรุงและทดสอบเพื่อให้แน่ใจว่าไม่มีการรั่วไหลของทรัพยากร


However, it is very possible to introduce these problems into your app. For example, you might be creating and using database connections without closing them. This would cause your database connection pool to be exhausted, and eventually cause the system to grind to a halt. When using custom Java or JDBC code in a BeanShell script or custom plugin, database connections must be closed in a try-catch finally loop e.g.

但是,将这些问题引入您的应用程序是非常可能的。例如,您可能正在创建和使用数据库连接而不关闭它们。这将导致您的数据库连接池耗尽,并最终导致系统停止。在BeanShell脚本或自定义插件中使用自定义Java或JDBC代码时,必须在try-catch finally循环中关闭数据库连接,例如

อย่างไรก็ตามเป็นไปได้มากที่จะแนะนำปัญหาเหล่านี้ในแอปพลิเคชันของคุณ ตัวอย่างเช่นคุณอาจสร้างและใช้การเชื่อมต่อฐานข้อมูลโดยไม่ปิด นี่จะทำให้พูลการเชื่อมต่อฐานข้อมูลของคุณหมดและในที่สุดก็ทำให้ระบบหยุดทำงาน เมื่อใช้รหัส Java หรือ JDBC ที่กำหนดเองในสคริปต์ BeanShell หรือปลั๊กอินที่กำหนดเองการเชื่อมต่อฐานข้อมูลจะต้องปิดในการลอง catch-loop ในที่สุดเช่น



Connection con = null;
try {
   // get connection
   con = datasource.getConnection();
   
   // more processing
} finally {
   // close connection
   try {
       if (con != null) {
           con.close();
       }
   } catch (Exception e) {
   }
}


Likewise, any custom code that creates objects, network connections or file IO must release such resources in a try-finally block. An indication of unreleased memory would manifest itself in the Java VM memory usage, which would continually increase without reducing over time.

同样,任何创建对象,网络连接或文件IO的自定义代码都必须在try-finally块中释放这些资源。未释放的内存指示将显示在Java VM内存使用情况中,这将随着时间的推移不断增加。

ในทำนองเดียวกันรหัสที่กำหนดเองใด ๆ ที่สร้างวัตถุการเชื่อมต่อเครือข่ายหรือไฟล์ IO จะต้องปล่อยทรัพยากรเหล่านี้ในการลองบล็อกในที่สุด การบ่งชี้ของหน่วยความจำที่ยังไม่เผยแพร่จะแสดงตัวเองในการใช้หน่วยความจำ Java VM ซึ่งจะเพิ่มขึ้นอย่างต่อเนื่องโดยไม่ลดลงเมื่อเวลาผ่านไป


Using a tool like VisualVM, you will be able to monitor the memory usage.

使用像VisualVM这样的工具,您将能够监视内存使用情况。

เมื่อใช้เครื่องมืออย่าง VisualVM คุณจะสามารถตรวจสอบการใช้งานหน่วยความจำได้


The database connection usage can be monitored in your database server, or use the v6 Database Connection Monitoring and Leak Detection feature.

可以在数据库服务器中监视数据库连接的使用情况,也可以使用即将到来的v6 数据库连接监视和泄漏检测功能。

สามารถตรวจสอบการใช้การเชื่อมต่อฐานข้อมูลในเซิร์ฟเวอร์ฐานข้อมูลของคุณหรือใช้คุณสมบัติ Database Connection Monitoring and Leak Detection v6 ที่กำลังจะมีขึ้น



 



Optimize your App and Database Queries

优化您的应用程序和数据库查询

เพิ่มประสิทธิภาพแอปพลิเคชันและแบบสอบถามฐานข้อมูลของคุณ


Joget Workflow has been thoroughly profiled and optimized to ensure that there is minimal overhead at the platform level. However, in enterprise apps that rely on dynamic data, each page request would require many database queries. Database calls are slow not just in query execution, but especially in network I/O. In most cases, database calls are the main performance bottlenecks that cause lengthy page response times and limit scalability.

Joget Workflow已经过彻底的分析和优化,以确保平台级别的开销很小。但是,在依赖动态数据的企业应用程序中,每个页面请求都需要许多数据库查询。数据库调用不仅在查询执行中很慢,而且在网络I / O中尤其如此。在大多数情况下,数据库调用是造成冗长的页面响应时间和限制可伸缩性的主要性能瓶颈。

Joget Workflow ได้รับการวิเคราะห์อย่างละเอียดและปรับให้เหมาะสมเพื่อให้แน่ใจว่าค่าใช้จ่ายในระดับแพลตฟอร์มนั้นน้อยที่สุด อย่างไรก็ตามในแอปพลิเคชันระดับองค์กรที่ใช้ข้อมูลแบบไดนามิกการร้องขอแต่ละหน้าต้องมีการสืบค้นฐานข้อมูลจำนวนมาก การเรียกฐานข้อมูลไม่เพียง แต่ช้าในการประมวลผลแบบสอบถาม แต่โดยเฉพาะในเครือข่าย I / O ในกรณีส่วนใหญ่การเรียกฐานข้อมูลเป็นปัญหาคอขวดของประสิทธิภาพหลักที่ทำให้เกิดเวลาตอบสนองของหน้าเว็บที่ยาวนานและจำกัดขีดความสามารถในการขยาย


It is therefore significant to minimize the number of database calls that are made in the app. Check through your app to ensure that any database calls (or processing) are really necessary, if not remove them.

因此,尽量减少在应用程序中进行的数据库调用次数。检查你的应用程序,以确保任何数据库调用(或处理)是真正必要的,如果不删除它们。

ดังนั้นลดจำนวนการเรียกฐานข้อมูลที่เกิดขึ้นในแอปพลิเคชันของคุณ ตรวจสอบแอปพลิเคชันของคุณเพื่อให้แน่ใจว่าการเรียกฐานข้อมูล (หรือการประมวลผล) มีความจำเป็นจริงๆถ้าไม่ลบออก


This also applies not just to the main userview page, but also in the userview menus. For example, displaying a count of items in the menus incur a potentially slow database query, so you need to make a decision on whether or not to display it. You can test the performance of a page with and without menus by using the Userview Embedded Mode.

In the upcoming v6, there will be a new Userview Caching feature to optionally cache userview pages and menus for a significant performance boost.

这不仅适用于主用户视图页面,也适用于用户视图菜单。例如,在菜单中显示项目计数会导致数据库查询的速度变慢,因此您需要决定是否显示该项目。您可以使用Userview 嵌入式模式来测试带菜单和不带菜单的页面性能  。

在即将到来的v6中,将会有一个新的用户视图缓存功能来选择性地缓存用户视图页面和菜单,以显着提升性能。

สิ่งนี้ไม่เพียงใช้กับหน้ามุมมองผู้ใช้หลัก แต่รวมถึงเมนูมุมมองผู้ใช้ ตัวอย่างเช่นการแสดงจำนวนรายการในเมนูสามารถชะลอการสืบค้นฐานข้อมูลดังนั้นคุณต้องตัดสินใจว่าจะแสดงรายการนั้นหรือไม่ คุณสามารถใช้ Embedded Mode Userview เพื่อทดสอบประสิทธิภาพของเพจที่มีและไม่มีเมนู ใน v6 ที่กำลังมาถึงจะมีคุณลักษณะการแคชมุมมองผู้ใช้ใหม่เพื่อเลือกเพจการดูแคชและเมนูของผู้ใช้เพื่อปรับปรุงประสิทธิภาพการทำงาน



 



Tune the Database and Application Server

调整数据库和应用程序服务器

ปรับแต่งฐานข้อมูลและแอปพลิเคชันเซิร์ฟเวอร์



You should optimize custom SQL queries that are used in your app, as slow queries are very common bottlenecks. In MySQL for example, you can use the  EXPLAIN command  to help you determine the execution plan of your queries, and find ways to optimize them.

您应该优化在您的应用程序中使用的自定义SQL查询,因为慢速查询是非常常见的瓶颈。例如,在MySQL中,您可以使用EXPLAIN  命令来帮助您确定查询的执行计划,并找到优化它们的方法。     

คุณควรเพิ่มประสิทธิภาพการสืบค้น SQL แบบกำหนดเองที่ใช้ในแอปของคุณเนื่องจากการสืบค้นที่ช้าเป็นปัญหาคอขวดที่พบบ่อยมาก ตัวอย่างเช่นใน MySQL คุณสามารถใช้คำสั่งอธิบายเพื่อช่วยคุณกำหนดแผนการดำเนินการของแบบสอบถามและค้นหาวิธีเพิ่มประสิทธิภาพคำสั่งเหล่านั้น


For apps that require a lot of database queries, you would want to optimize both your database and database server configuration. Depending on the type of database server used, your database administrator would be best placed to perform such tuning based on your usage pattern. For example, MySQL has a section on optimization in the documentation http://dev.mysql.com/doc/refman/5.6/en/optimization.html.

对于需要大量数据库查询的应用程序,您需要优化数据库和数据库服务器配置。根据所使用的数据库服务器的类型,您的数据库管理员将最适合根据您的使用模式执行此类调整。例如,MySQL在文档http://dev.mysql.com/doc/refman/5.6/en/optimization.html中有一个关于优化的部分。

สำหรับแอปพลิเคชันที่ต้องมีการสืบค้นฐานข้อมูลจำนวนมากคุณต้องปรับแต่งฐานข้อมูลและกำหนดค่าเซิร์ฟเวอร์ฐานข้อมูลของคุณให้เหมาะสม ขึ้นอยู่กับประเภทของเซิร์ฟเวอร์ฐานข้อมูลที่ใช้ผู้ดูแลระบบฐานข้อมูลของคุณจะเหมาะสมที่สุดในการปรับเปลี่ยนตามรูปแบบการใช้งานของคุณ ตัวอย่างเช่น MySQL มีส่วนในการเพิ่มประสิทธิภาพในเอกสาร http://dev.mysql.com/doc/refman/5.6/en/optimization.html


There are some additional information at Deployment Best Practices#DatabaseConfiguration.

 部署最佳实践#DatabaseConfiguration有一些额外的信息  。

มีข้อมูลเพิ่มเติมบางอย่างที่ Deployment Best Practices#DatabaseConfiguration.


If there are a lot of concurrent requests to your app, it might also be prudent to tune your application server as per Deployment Best Practices#WebApplicationServerConfiguration.

如果对您的应用程序有大量的并发请求,那么按照部署最佳实践#WebApplicationServerConfiguration调整应用程序服务器也是明智之举。

หากคุณมีคำขอพร้อมกันจำนวนมากสำหรับแอปพลิเคชันของคุณคุณควรปรับเปลี่ยนแอปพลิเคชันเซิร์ฟเวอร์ตามแนวทางปฏิบัติที่ดีที่สุดในการปรับใช้ Deployment Best Practices#WebApplicationServerConfiguration.


Do update your database server to the latest MySQL releases. New stable database engine releases usually have performance improvments.

务必将数据库服务器更新为最新的MySQL版本。新的稳定数据库引擎版本通常会提高性能。

ตรวจสอบให้แน่ใจว่าได้อัพเดตเซิร์ฟเวอร์ฐานข้อมูลเป็นเวอร์ชัน MySQL ล่าสุด เวอร์ชันเอ็นจิ้นฐานข้อมูลที่เสถียรใหม่มักจะปรับปรุงประสิทธิภาพ


If you use a lot of form grids with parent and child database tables, do add indexes to your foreign key child table. This will speed up retrieval of the child form records.

如果您对父数据库表和子数据库表使用大量表单网格,请向您的外键子表添加索引。这将加速子窗体记录的检索。

ถ้าคุณใช้กริดฟอร์มจำนวนมากกับตารางฐานข้อมูลหลักและลูก ให้เพิ่ม foreign key ลงในตารางลูกของคุณ สิ่งนี้จะเพิ่มความเร็วในการดึงข้อมูลบันทึกย่อย

 



Load Test your App and Server Sizing

加载测试您的应用程序和服务器大小

โหลดการทดสอบแอปและขนาดเซิร์ฟเวอร์ของคุณ


There are many factors involved in determining the server specifications needed to run Joget Workflow effectively. These are some of the non-conclusive factors:

确定有效运行Joget Workflow所需的服务器规格涉及许多因素。这些是一些非决定性的因素:

มีปัจจัยหลายอย่างที่เกี่ยวข้องในการพิจารณาข้อกำหนดของเซิร์ฟเวอร์ที่จำเป็นในการเรียกใช้ Joget Workflow อย่างมีประสิทธิภาพ เหล่านี้เป็นปัจจัยที่สรุปไม่ได้:


  1. Total number of users

    1. 用户总数

    จำนวนผู้ใช้ทั้งหมด

  2. Maximum expected concurrent users

    1. 最大预期并发用户数

    ผู้ใช้งานพร้อมกันสูงสุดที่คาดไว้

  3. Number of apps running on the platform

    1. 平台上运行的应用程序的数量

    จำนวนแอพที่ใช้งานบนแพลตฟอร์ม

  4. Complexity of each of the apps

    1. 每个应用程序的复杂性
    ความซับซ้อนของแต่ละแอพ
  5. Amount of data generated in each app

    1. 每个应用程序生成的数据量
    จำนวนข้อมูลที่สร้างขึ้นในแต่ละแอป 
  6. Network infrastructure

    1. 网络基础设施

    โครงสร้างพื้นฐานเครือข่าย

For example, an environment with a small number of users running a heavily-used complex app might require more resources than an environment with large number of users running some simple apps only once a day.

例如,运行使用频繁的复杂应用程序的用户数量较少的环境可能比运行一些简单应用程序的用户数量大的环境需要更多资源。

ตัวอย่างเช่นสภาพแวดล้อมที่มีผู้ใช้จำนวนน้อยที่ใช้แอปที่ซับซ้อนที่ใช้งานหนักอาจต้องใช้ทรัพยากรมากกว่าสภาพแวดล้อมที่มีผู้ใช้จำนวนมากที่ใช้แอปง่าย ๆ เพียงวันละครั้ง


So based only on number of maximum and concurrent users, you wouldn't be able to predict what is needed. Usually installations would start with a single application server first, and scale up or cluster when necessary.

因此,仅根据最大和并发用户的数量,您将无法预测需要什么。通常,安装将首先从单个应用程序服务器开始,然后在需要时进行扩展或集群。

ดังนั้นขึ้นอยู่กับจำนวนผู้ใช้สูงสุดและพร้อมกัน คุณจะไม่สามารถคาดการณ์สิ่งที่ต้องการ โดยปกติการติดตั้งจะเริ่มต้นด้วยแอปพลิเคชันเซิร์ฟเวอร์เดียวก่อนและขยายขนาดหรือคลัสเตอร์เมื่อจำเป็น


To determine the actual requirement for your app and usage, it is best to perform load testing in your environment. There are many free and commercial load testing available, there is an article using the open source Apache JMeter tool at Joget Workflow Clustering and Performance Testing on Amazon Web Services (AWS)

要确定您的应用和使用的实际要求,最好在您的环境中执行负载测试。有许多免费和商业的负载测试可用,有一篇文章使用开源的JMeter工具在  Joget工作流集群和亚马逊网络服务(AWS)上进行性能测试。

เพื่อกำหนดความต้องการที่แท้จริงสำหรับแอปและการใช้งานของคุณวิธีที่ดีที่สุดคือทำการทดสอบโหลดในสภาพแวดล้อมของคุณ มีการทดสอบโหลดฟรีและเชิงพาณิชย์มากมายมีบทความที่ใช้เครื่องมือโอเพนซอร์ส Apache JMeter ที่ Joget Workflow Clustering and Performance Testing on Amazon Web Services (AWS)


 



Introduce Clustering and Load Balancing

介绍集群和负载平衡

แนะนำการทำคลัสเตอร์และโหลดบาลานซ์


When you have optimized your apps, you can increase your server capacity as appropriate to handle increasing load (vertical scaling). You can also start to consider performing horizontal scaling i.e. to cluster or load balance your installation. This can not only handle increased load, but also offer high availability. Read more on this at Deployment Best Practices#ClusteringandLoadBalancing.

在优化应用程序时,可以根据需要增加服务器容量以处理增加的负载(垂直缩放)。您也可以开始考虑执行水平缩放,即对您的安装进行集群或负载平衡。这不仅可以处理增加的负载,而且还提供高可用性。在部署最佳实践#ClusteringandLoadBalancing上阅读更多  。

เมื่อปรับแต่งแอปพลิเคชันของคุณให้เหมาะสมคุณสามารถเพิ่มความจุของเซิร์ฟเวอร์ได้ตามต้องการเพื่อรองรับการโหลดที่เพิ่มขึ้น คุณยังสามารถเริ่มคิดเกี่ยวกับการปรับสเกลแนวนอนซึ่งก็คือการจัดกลุ่มหรือโหลดบาลานซ์ที่คุณติดตั้ง สิ่งนี้ไม่เพียงจัดการกับโหลดที่เพิ่มขึ้น แต่ยังให้ความพร้อมใช้งานสูง อ่านเพิ่มเติมเกี่ยวกับแนวทางปฏิบัติ Deployment Best Practices#ClusteringandLoadBalancing.