Performance monitoring method and device for Web application, equipment and medium
By reading the monitoring service configuration file and obtaining device performance monitoring data when the web application is started, the problem of insufficient comprehensive performance monitoring in the existing technology is solved, and a more comprehensive and reliable performance monitoring of web application is achieved.
Patent Information
- Application Number
- CN202311128816.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-01
- Publication Date
- 2025-03-11
AI Technical Summary
When performing performance monitoring of web applications, the prior art cannot fully read the performance data of the device running, resulting in unreliable monitoring results.
When the web application starts, read the monitoring service configuration file, determine the monitoring service policy, and obtain the device performance monitoring data when the web application is running to determine the performance monitoring results.
By obtaining device performance monitoring data, the comprehensiveness and reliability of web application performance monitoring is improved, and performance problems can be discovered and solved in a timely manner, improving user experience.
Smart Images

Figure CN119597597A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of Internet technology, and specifically relates to a performance monitoring method, device, equipment and medium for a Web application. Background Art
[0002] With the development of the Internet industry, millions of companies use the Internet as a high-efficiency communication channel. It has become very common to use Web applications to interact with users, and it has become very important to monitor the performance of Web applications.
[0003] In the related art, the monitoring method of Web applications is mainly to simulate client requests, use programs to simulate browsers to send requests to Web applications, record the time taken to process each user request through server-side logs, and analyze the performance issues of Web applications based on the time taken to process requests. The specific method is to use tools such as wget or httpclient to access certain URLs (Uniform Resource Locator), record the server's response and loading time, analyze the recorded logs, and use the URLs that take a long time as the basis for optimizing the performance of Web applications.
[0004] Since the performance monitoring of Web applications in the existing related technologies is mainly aimed at monitoring the page performance of the application, and it is impossible to read the device performance related data generated when the device where the Web application is located is running. Therefore, when using the existing related technologies to monitor the performance of Web applications, there is a problem that the performance monitoring is not comprehensive enough, which leads to the problem that the monitoring results are not reliable enough. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a performance monitoring method, apparatus, device and medium for a Web application, which can solve the problem that the performance monitoring of a Web application is not comprehensive enough, which leads to unreliable monitoring results, when the related technology performs performance monitoring on the Web application. By reading a monitoring service configuration file for the Web application when the Web application is started, determining a monitoring service strategy, and obtaining device performance monitoring data when the Web application is running, and determining the performance monitoring result of the Web application, the purpose of monitoring the device performance data when the Web application is running can be achieved, and the comprehensiveness of the performance monitoring of the Web application is improved. At the same time, by using different monitoring strategies to monitor different performances of the Web application when it is running, the reliability of the performance monitoring of the Web application can be improved.
[0006] In a first aspect, an embodiment of the present application provides a performance monitoring method for a Web application, wherein the Web application runs on an electronic device and is developed based on an Electron framework; the method comprises:
[0007] When the Web application is started, reading a monitoring service configuration file for the Web application;
[0008] Determining a monitoring service policy for the Web application according to the monitoring service configuration file;
[0009] Acquire device performance monitoring data when the Web application is running according to the monitoring service strategy;
[0010] A performance monitoring result of the Web application is determined according to the device performance monitoring data.
[0011] Further, after determining the monitoring service policy for the Web application according to the monitoring service configuration file, the method further includes:
[0012] Acquire page performance monitoring data when the Web application is running according to the monitoring service strategy;
[0013] Accordingly, determining the performance monitoring result of the Web application according to the device performance monitoring data includes:
[0014] The performance monitoring result of the Web application is determined according to the device performance monitoring data and / or the page performance monitoring data.
[0015] Furthermore, after reading the monitoring service configuration file for the Web application, the method further includes:
[0016] Locally storing the monitoring service configuration file;
[0017] Identify whether there is an update operation of the monitoring service configuration file;
[0018] If it exists, an update request for the monitoring service configuration file is generated to synchronize the updated monitoring service configuration file to the local computer.
[0019] Further, determining a monitoring service policy for the Web application according to the monitoring service configuration file includes:
[0020] Read the monitoring object, monitoring cycle and monitoring threshold for the Web application in the monitoring service configuration file;
[0021] A monitoring service policy is generated according to the monitoring object, the monitoring cycle and the monitoring threshold.
[0022] Furthermore, the monitoring objects include CPU data, memory data, and GC recovery data;
[0023] Accordingly, obtaining device performance monitoring data when the Web application is running according to the monitoring service strategy includes:
[0024] If the monitoring object is CPU data, the CPU usage rate of the Web application when it is running is obtained through the app.getAppMetrics function;
[0025] If the monitoring object is memory data, the memory occupied by the entire Web application when the Web application is running is obtained through the app.getAppMetrics function; and / or the memory occupied by each thread of the Web application when the Web application is running is obtained through the first preset interface;
[0026] If the monitoring object is GC recycling data, the number of GC recycling times when the Web application is running is obtained through a second preset interface.
[0027] Furthermore, obtaining the GC recycling times of the electronic device when the Web application is running through the second preset interface includes:
[0028] The number of GC collection times when the Web application is running is monitored through the NAN_GC_CALLBACK interface of the C++ extension library of Node.js enabled when the Web application is started.
[0029] Further, generating a monitoring service strategy according to the monitoring object, the monitoring cycle and the monitoring threshold includes:
[0030] If the monitored object is CPU data, identifying whether the CPU usage rate is continuously higher than a set usage rate threshold within a first preset time period;
[0031] If the monitoring object is memory data, identifying whether the memory occupied by the entire Web application is continuously higher than the first set memory threshold within a second preset time period; and / or identifying whether the memory occupied by each thread of the Web application is continuously higher than the second set memory threshold within the second preset time period;
[0032] If the monitoring object is GC recycling data, it is identified whether the number of GC recycling times is higher than a set recycling times threshold within a third preset time period.
[0033] In a second aspect, an embodiment of the present application provides a performance monitoring device for a Web application, wherein the Web application runs on an electronic device and is developed based on an Electron framework; the device comprises:
[0034] A configuration file reading module, used to read a monitoring service configuration file for the Web application when the Web application is started;
[0035] A policy determination module, used to determine a monitoring service policy for the Web application according to the monitoring service configuration file;
[0036] A monitoring data acquisition module, used to acquire device performance monitoring data when the Web application is running according to the monitoring service strategy;
[0037] The monitoring result determination module is used to determine the performance monitoring result of the Web application according to the device performance monitoring data.
[0038] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0039] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0040] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0041] In an embodiment of the present application, when a Web application is started, a monitoring service configuration file for the Web application is read; a monitoring service strategy for the Web application is determined according to the monitoring service configuration file; device performance monitoring data when the Web application is running is obtained according to the monitoring service strategy; and performance monitoring results of the Web application are determined according to the device performance monitoring data. Through the above-mentioned performance monitoring method for Web applications, the problem that the performance monitoring of Web applications is not comprehensive enough in the related technology, which leads to unreliable monitoring results, can be solved. By reading the monitoring service configuration file for the Web application when the Web application is started, determining the monitoring service strategy, and obtaining the device performance monitoring data when the Web application is running, and determining the performance monitoring results of the Web application, the purpose of monitoring the device performance data when the Web application is running can be achieved, and the comprehensiveness of the performance monitoring of the Web application is improved. At the same time, by using different monitoring strategies to monitor different performances of the Web application when it is running, the reliability of the performance monitoring of the Web application can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flowchart of a method for monitoring the performance of a Web application provided in an embodiment of the present application;
[0043] Figure 2 It is a flowchart of a method for monitoring the performance of a Web application provided in an embodiment of the present application;
[0044] Figure 3 is a schematic diagram of the structure of a performance monitoring device for a Web application provided in an embodiment of the present application;
[0045] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0048] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0049] The following is a detailed description of the Web application performance monitoring method, device, equipment and medium provided by the embodiments of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0050] Figure 1 1 is a flow chart of a method for monitoring the performance of a Web application provided in an embodiment of the present application. The Web application is run on an electronic device and is developed based on the Electron framework. Figure 1 As shown, the specific steps include:
[0051] S101, when a Web application is started, reading a monitoring service configuration file for the Web application;
[0052] First of all, the usage scenario of this solution can be a scenario of performance monitoring of Web applications developed based on the Electron framework.
[0053] Based on the above usage scenarios, it can be understood that the executor of this application can be an electronic device with the ability to read configuration files, obtain data, and monitor performance, such as: mobile phones, computers and other smart terminals, and no excessive restrictions are made here.
[0054] Among them, the Web (World Wide Web), also known as the World Wide Web, is a global, dynamically interactive, cross-platform distributed graphic information system based on hypertext and HTTP. It is a network service built on the Internet. It provides a graphical, easy-to-access and intuitive interface for viewers to find and browse information on the Internet. The documents and hyperlinks organize the information nodes on the Internet into an interconnected network structure.
[0055] A web application can be a computer program that uses a web browser and web technology to perform tasks on the Internet. Web applications use a combination of server-side scripts (PHP and ASP) to handle the storage and retrieval of information, and client-side scripts (JavaScript and HTML) to present information to users, allowing users to interact with businesses using online forms, content management systems, and shopping carts. Web applications are usually written in browser-supported languages (such as JavaScript and HTML) because these languages rely on the browser to present program executable files. Some applications are dynamic and require server-side processing, while other applications are completely static and do not require any processing on the server.
[0056] Web applications require a web server to manage requests from clients, an application server to perform the requested tasks, and sometimes a database to store information. The process of using a web application is that the user triggers a request to the web server through the Internet through a web browser or the user interface of the application; the web server forwards this request to the appropriate web server; the web server performs the requested task, such as querying a database or processing data, and then generates the results of the requested data; the web server sends the processed data or the requested information or the results of the processed data to the web server; the web server responds to the client with the requested information, which then appears on the user's display.
[0057] The web application in this solution is an application developed based on the Electron framework.
[0058] Electron is a desktop application development framework based on the Chromium kernel and Node.js. It allows the development of desktop GUI applications using Node.js (as the backend) and Chromium (as the frontend). It can be simply understood as an application developed based on a browser, and each application window will load a web page. Electron can be used to build cross-platform desktop applications with HTML, CSS, and JavaScript. It achieves this by combining Chromium and Node.js into a running environment. The application can be packaged on systems such as Mac, Windows, and Linux.
[0059] The monitoring service configuration file of the Web application may be a file for specifying the monitoring configuration and monitoring strategy for the performance monitoring of the current Web application, including: whether to enable the monitoring service, the inspection strategy adopted when monitoring the current Web application, the inspection frequency, the frequency of reporting the inspection results, and the address of the current Web application, etc. The performance monitoring of the current Web application may include the page performance and device performance of the Web application.
[0060] In one embodiment, a user can input a URL and a keyword to be searched or browsed through a browser or a user interface of an application, and the device terminal corresponding to the user starts the Web application after receiving the user's input request. When the Web application is started, the monitoring service configuration file for the Web application is read. The monitoring service configuration file of the Web application can determine the file reading path of the monitoring service configuration file according to the file directory of the Web application, and then read the monitoring service configuration file of the Web application; the monitoring service configuration file for the Web application can also be obtained by directly writing a reading code, and the specific acquisition method is not limited here.
[0061] In a feasible embodiment, optionally, after reading the monitoring service configuration file for the Web application, the method further includes:
[0062] Locally storing the monitoring service configuration file;
[0063] Identify whether there is an update operation of the monitoring service configuration file;
[0064] If it exists, an update request for the monitoring service configuration file is generated to synchronize the updated monitoring service configuration file to the local computer.
[0065] The update operation of the monitoring service configuration file may be an operation to modify and update the original monitoring policy of the Web application, such as an update operation of the monitoring data threshold and an update operation of the monitoring content. After the configuration of the Web application with abnormal monitoring data is modified, the update content of the monitoring service configuration file of the Web application may be determined according to the configuration parameters of the modified Web application. The update request of the monitoring service configuration file may be a request to modify the original monitoring service configuration file stored locally.
[0066] In one embodiment, the monitoring service configuration file can be stored locally, and the monitoring service configuration file is stored in the memory of the terminal device where the client is located. By identifying the monitoring data and the monitoring content field in the monitoring service configuration file, it is identified whether the monitoring service configuration file has been modified, and then it is determined whether there is an update operation of the monitoring service configuration file. If there is an update operation, an update request for the monitoring service configuration file is generated to synchronize the updated monitoring service configuration file to the local.
[0067] In the embodiment of the present application, after identifying the existence of an update operation of the monitoring service configuration file, an update request for the monitoring service configuration file is generated to synchronize the updated monitoring service configuration file to the local computer. The latest monitoring service configuration can be used when monitoring the Web application, thereby improving the reliability of monitoring the Web application.
[0068] S102, determining a monitoring service policy for the Web application according to the monitoring service configuration file;
[0069] The monitoring service strategy includes the monitoring object, monitoring cycle, and monitoring threshold corresponding to the monitoring object for monitoring the Web application. The monitoring threshold may be the maximum value that the monitoring object can reach when the Web application is running normally, and the maximum value may be used as the performance indicator of the Web application. The monitoring object for monitoring the Web application may include the page performance and / or device performance of the Web application.
[0070] In one embodiment, the monitoring object, monitoring cycle and monitoring threshold to be monitored can be determined according to the monitoring service configuration file, and the monitoring content, monitoring duration and the maximum value corresponding to the monitoring content to be monitored for the Web application can be determined according to the monitoring object, monitoring cycle and monitoring threshold. Since different Web applications have different configuration parameters and operating standards, different monitoring strategies for different Web applications can be different, that is, different performance indicators can be formulated according to the specific operating standards of the Web applications.
[0071] S103, obtaining device performance monitoring data when the Web application is running according to the monitoring service policy;
[0072] The device performance monitoring data may be the actual data displayed on the terminal device when the Web application is running, such as the instantaneous CPU occupancy rate, memory occupancy data, and GC frequency caused by the Web application running. In addition, other device performance monitoring data may also be included, such as the number of processes created when the Web application is running and the number of threads included in each process.
[0073] In one embodiment, the monitoring service policy can be used to determine the monitored object, monitoring duration, and monitoring threshold corresponding to each monitored object for the current Web application. For example, if the monitoring service policy is "frequentGC:1min:20", it means that the GC frequency performance of the Web application needs to be monitored, the monitoring duration is 1 minute, and the monitoring threshold is 20 times. After determining which device performance of the Web application is to be monitored, different interfaces or functions can be used to obtain the device performance monitoring data of the Web application according to the characteristics of the device performance.
[0074] In this embodiment, the Web application is built based on the Electron framework, so the instantaneous CPU occupancy rate and memory occupancy data when the Web application is running can be obtained according to the app.getAppMetrics function provided by the Electron framework. Since Electron is a desktop application development framework based on the Chromium kernel and Node.js, Chromium and Node.js are both developed based on the v8 engine, and the rendering process of the Electron framework can enable Node.js, therefore, the GC of the v8 engine can be monitored through NAN_GC_CALLBACK in the C++ extension library Nan of Node.js, and an event is thrown each time the GC is triggered and carries the GC data, and the number of GCs is counted according to the rules of the policy.
[0075] S104: Determine a performance monitoring result of the Web application according to the device performance monitoring data.
[0076] The performance monitoring result of the Web application may be whether the device performance monitoring data exceeds a monitoring threshold or meets a monitoring standard when the Web application is running.
[0077] In one embodiment, the performance monitoring result of the Web application can be determined based on the device performance monitoring data and the monitoring threshold. For example, if the monitoring service policy is "frequentGC:1min:20", that is, the GC frequency monitoring threshold of the Web application is 20 times per minute, when it is detected that the actual GC of the Web application exceeds 20 times within one minute, it can be determined that the GC monitoring result of the Web application does not meet the performance monitoring standard.
[0078] In one embodiment, when the performance monitoring result of the Web application exceeds the monitoring threshold or does not meet the performance monitoring standard, the current device corresponding to the Web application and the resource occupancy of the Web application can be reported to the server for persistence, and then used for analysis and alarm, so as to provide a basis for making targeted optimization strategies and decisions. For example: when the number of GCs triggered within a certain period of time exceeds the threshold, the GC data dubiousStats and the system context data sysStats are reported to the monitoring server, and the monitoring server then issues information alarms according to the configured alarm rules.
[0079] In a feasible embodiment, optionally, after determining the monitoring service policy for the Web application according to the monitoring service configuration file, the method further includes:
[0080] Acquire page performance monitoring data when the Web application is running according to the monitoring service strategy;
[0081] Accordingly, determining the performance monitoring result of the Web application according to the device performance monitoring data includes:
[0082] The performance monitoring result of the Web application is determined according to the device performance monitoring data and / or the page performance monitoring data.
[0083] The page performance monitoring data may include data such as page loading and feedback speed of a Web application in response to a user request, such as current page loading time, total page loading time, first byte time, DNS time, TCP time, page rendering, download speed, page fluency, network packet loss rate, network latency, request response time, transaction response time, and number of concurrent users, etc. The page performance monitoring data affects the user retention rate to a certain extent.
[0084] In one embodiment, the page performance monitoring data of the Web application during runtime can be obtained according to the monitoring service strategy. The page performance monitoring data of the Web application during runtime can be detected by using the browser's Performance API (front-end performance monitoring interface). Among them, the API (Application Programming Interface) is a combination of a group of APIs, including: Resource Timing API (resource loading network timing interface): time-consuming information related to the loading of web page resources (scripts, styles, pictures, etc.), defining the interface Performance ResourceTiming; Navigation Timing API (javascript interface for accurate performance measurement): from the beginning of page navigation to the end of the load event, the time-consuming information of the intermediate process is defined, and the interface Performance NavigationTiming is defined, which is inherited from the Performance Resource Timing interface; Paint Timing API (page construction rendering time point interface): time-consuming information related to web page drawing, defining the interface Performance Paint Timing. The above three interfaces are all inherited from the Performance Entry interface in the Performance Timeline API (an interface for collecting various performance indicators throughout the life cycle), so each interface instance is called Entry. Performance Entry defines four basic read-only properties: name, entryType, startTime, and duration. NavigationTiming API is a JavaScript API that can accurately measure performance on the Web. This API provides a simple way to obtain accurate and detailed time status of page navigation and loading events. The server can obtain page performance monitoring data when the Web application is running in real time or periodically through the Navigation Timing API. Users can also open the console in Chrome, enter performance in the command line, click and view its timing properties. The Navigation Timing API can accurately and real-time obtain the page loading speed of the Web application when it is running in the actual network environment.
[0085] In one embodiment, the performance index or monitoring threshold of the Web application can be determined according to the application configuration, operating environment, and average application load of the Web application, and the performance monitoring result of the Web application can be determined according to the device performance monitoring data and / or the page performance monitoring data. The performance index or monitoring threshold of the page performance monitoring data can be the maximum value of time data such as loading time and rendering time.
[0086] In the embodiment of the present application, the page performance monitoring data of the Web application during runtime is obtained according to the monitoring service strategy, and the performance monitoring result of the Web application is determined according to the device performance monitoring data and / or the page performance monitoring data, which can further improve the comprehensiveness of the Web application performance monitoring and the reliability of the monitoring results. At the same time, by monitoring the page performance of the Web application during runtime, it is helpful to timely discover and solve the problems that cause slow application response, thereby improving the user experience, and improving user satisfaction and retention rate.
[0087] The technical solution provided in the embodiment of the present application is to read the monitoring service configuration file for the Web application when the Web application is started; determine the monitoring service strategy for the Web application according to the monitoring service configuration file; obtain the device performance monitoring data when the Web application is running according to the monitoring service strategy; and determine the performance monitoring result of the Web application according to the device performance monitoring data. Through the above-mentioned performance monitoring method of Web application, the problem that the performance monitoring of Web application is not comprehensive enough in the related technology, which leads to unreliable monitoring results, can be solved. By reading the monitoring service configuration file for the Web application when the Web application is started, determining the monitoring service strategy, and obtaining the device performance monitoring data when the Web application is running, and determining the performance monitoring result of the Web application, the purpose of monitoring the device performance data when the Web application is running can be achieved, and the comprehensiveness of the performance monitoring of the Web application is improved. At the same time, by using different monitoring strategies to monitor different performances of the Web application when it is running, the reliability of the performance monitoring of the Web application can be improved.
[0088] Figure 2 Schematic diagram of the performance monitoring method of a Web application provided in the embodiment of the present application. Figure 2 As shown, the specific steps include:
[0089] S201, when a Web application is started, reading a monitoring service configuration file for the Web application;
[0090] S202, reading the monitoring object, monitoring period and monitoring threshold for the Web application in the monitoring service configuration file;
[0091] The monitoring object may be the performance monitored during the operation of the Web application, such as request response time, CPU instantaneous occupancy, and memory occupancy. The monitoring period may be the period for monitoring and reporting different performances of the Web application. The monitoring threshold may be the threshold of each application performance when the Web application is operating normally, including time threshold, memory occupancy threshold, and number threshold. Different Web applications have different performance monitoring standards, i.e., different monitoring thresholds.
[0092] In one embodiment, the monitoring object, monitoring period and monitoring threshold for the Web application in the monitoring service configuration file may be read by coding.
[0093] S203, generating a monitoring service policy according to the monitoring object, the monitoring cycle and the monitoring threshold;
[0094] In one embodiment, the performance of monitoring the Web application can be determined according to the monitoring object, the monitoring duration of the monitoring object and the monitoring result reporting time interval can be determined according to the monitoring cycle, and whether the performance monitoring result of the monitoring object conforms to the data of the normal operation of the Web application can be determined according to the monitoring threshold. When the monitoring data of the monitoring object is greater than the monitoring threshold, an alarm message is generated and sent to a monitoring server, or the monitoring server issues an information alarm according to the configured alarm rules, so that the Web application designer can optimize the performance.
[0095] S204, obtaining device performance monitoring data when the Web application is running according to the monitoring service policy;
[0096] In a feasible embodiment, optionally, the monitoring objects include CPU data, memory data, and GC recovery data;
[0097] Accordingly, obtaining device performance monitoring data when the Web application is running according to the monitoring service strategy includes:
[0098] If the monitoring object is CPU data, the CPU usage rate of the Web application when it is running is obtained through the app.getAppMetrics function;
[0099] If the monitoring object is memory data, the memory occupied by the entire Web application when the Web application is running is obtained through the app.getAppMetrics function; and / or the memory occupied by each thread of the Web application when the Web application is running is obtained through the first preset interface;
[0100] If the monitoring object is GC recycling data, the number of GC recycling times when the Web application is running is obtained through a second preset interface.
[0101] Among them, the CPU data can be the utilization rate of the CPU when the Web application is running. The memory data can be the single process memory occupancy data and / or the total memory occupancy data when the Web application is running. The GC recovery data can be the number of GC recovery times per unit time. The GC (Garbage Collection) can effectively prevent memory leaks and effectively use the available memory. The garbage collector usually runs as a separate low-priority thread. Under normal circumstances, this thread will not be executed. Only when the virtual machine is idle or the current memory is insufficient, will it trigger execution, scan those objects that are not referenced by any program, and add them to the object collection to be recovered, and then perform the recovery operation. Memory processing is where developers are prone to problems. Forgetting or incorrectly recovering memory can cause instability or even crash of the program or system. The first preset interface can be some setting interfaces of Node.js of the Electron framework corresponding to the Web application, through which the memory occupied by a single process when the Web application is running per unit time can be obtained. The second preset interface can be an interface for the application to obtain the number of GC recovery times, for example: the NAN_GC_CALLBACK interface in the C++ extension library Nan of Node.js.
[0102] In one embodiment, the monitoring object of the Web application may include CPU data, memory data, and GC recovery data. If the monitoring object is CPU data, the CPU usage rate of the Web application during operation per unit time can be obtained through the app.getAppMetrics function provided by the Electron framework. If the monitoring object is memory data, the overall memory occupied space of the Web application during the operation of the Web application per unit time and / or the individual memory occupied space of each thread of the Web application during the operation of the Web application can be obtained through the app.getAppMetrics function provided by the Electron framework through the first preset interface. If the monitoring object is GC recovery data, the number of GC recovery times when the Web application is running is obtained through the second preset interface.
[0103] In the embodiment of the present application, the CPU usage rate of the Web application when it is running is obtained through the app.getAppMetrics function, the memory occupied space of the entire Web application when it is running is obtained through the app.getAppMetrics function and / or the memory occupied space of each thread of the Web application when it is running is obtained through the first preset interface, and the number of GC recycling times when the Web application is running is obtained through the second preset interface. This can improve the reliability and efficiency of obtaining monitoring data of the Web application monitoring object. At the same time, by obtaining the CPU data, memory data and GC recycling data of the Web application, potential performance problems can be discovered in time, so that application designers can expand or optimize the system in advance to avoid Web application performance problems caused by insufficient resources.
[0104] In a feasible embodiment, optionally, obtaining the number of GC recycling times of the electronic device when the Web application is running through the second preset interface includes:
[0105] The number of GC collection times when the Web application is running is monitored through the NAN_GC_CALLBACK interface of the C++ extension library of Node.js enabled when the Web application is started.
[0106] In one embodiment, since Electron is a desktop application development framework based on the Chromium kernel and Node.js, Chromium and Node.js are both developed based on the v8 engine, and the rendering process of the Electron framework can enable Node.js, the GC of the v8 engine can be monitored through the NAN_GC_CALLBACK interface in the C++ extension library Nan of Node.js. Each time the GC is triggered, an event is thrown and carries GC data, and the number of GC recycling times is counted according to the rules of the policy.
[0107] In the embodiment of the present application, the accuracy of the statistics of the GC recycling times when the Web application is running is improved by monitoring the GC recycling times when the Web application is running through the NAN_GC_CALLBACK interface of the C++ extension library of Node.js enabled when the Web application is started.
[0108] In a feasible embodiment, optionally, generating a monitoring service policy according to the monitoring object, the monitoring period, and the monitoring threshold includes:
[0109] If the monitored object is CPU data, identifying whether the CPU usage rate is continuously higher than a set usage rate threshold within a first preset time period;
[0110] If the monitoring object is memory data, identifying whether the memory occupied by the entire Web application is continuously higher than the first set memory threshold within a second preset time period; and / or identifying whether the memory occupied by each thread of the Web application is continuously higher than the second set memory threshold within the second preset time period;
[0111] If the monitoring object is GC recycling data, it is identified whether the number of GC recycling times is higher than a set recycling times threshold within a third preset time period.
[0112] Among them, the first preset duration may be the monitoring cycle duration for monitoring the CPU usage of the Web application. The usage rate threshold may be set to the instantaneous CPU usage when the Web application is running normally. The second preset duration may be the monitoring cycle duration for monitoring the memory occupied by the Web application. The first set memory threshold may be the maximum value of the total memory occupied by the application when the Web application is running normally. The second set memory threshold may be the maximum value of the memory occupied by any single thread of the application when the Web application is running normally. The third preset duration may be the monitoring cycle duration for monitoring the number of GC recycling times of the Web application. The recycling times threshold may be set to the maximum value of the number of GC recycling times when the Web application is running normally. Different Web applications have different operating standards, so the monitoring service strategies of different applications may be different.
[0113] In one embodiment, if the monitoring object is CPU data, it is identified whether the CPU usage rate is continuously higher than a set usage rate threshold within a first preset time period. For example:
[0114] The CPU usage is continuously above 80% for 30 minutes.
[0115] If the monitoring object is memory data, then identify whether the memory occupied by the entire Web application is continuously higher than the first set memory threshold within a second preset time period; and / or identify whether the memory occupied by each thread of the Web application is continuously higher than the second set memory threshold within the second preset time period. For example:
[0116] The memory of a single process of the application lasting 30 minutes is higher than 500M;
[0117] The total memory of the application is higher than 2G for 30 minutes;
[0118] The total memory of the application is higher than 2G for a continuous preset period of time and / or the memory of a single process of the application is higher than 500M for a continuous preset period of time.
[0119] If the monitoring object is GC recycling data, it is identified whether the number of GC recycling times is higher than the set recycling times threshold within a third preset time period.
[0120] The number of GCs in one minute exceeds 20;
[0121] The number of GCs in one hour exceeded the specification by 200 times;
[0122] The number of GCs in twelve hours exceeded 600;
[0123] The number of GCs in other preset time periods exceeds 600.
[0124] In an embodiment of the present application, if the monitored object is CPU data, it is identified whether the CPU usage rate is continuously higher than the set usage rate threshold within a first preset time period; if the monitored object is memory data, it is identified whether the overall memory occupation space of the Web application is continuously higher than the first set memory threshold within a second preset time period and / or it is identified whether the memory occupation space of each thread of the Web application is continuously higher than the second set memory threshold within the second preset time period; if the monitored object is GC recycling data, it is identified whether the number of GC recycling times is higher than the set recycling times threshold within a third preset time period. By determining different monitoring service strategies according to the characteristics of the monitored object, the scope of Web application performance monitoring can be expanded, thereby improving the comprehensiveness of Web application performance monitoring.
[0125] S205: Determine a performance monitoring result of the Web application according to the device performance monitoring data.
[0126] The technical solution provided in the embodiment of the present application can avoid the problem of insufficient comprehensiveness of Web application performance monitoring by reading the monitoring service configuration file, determining the monitoring object, monitoring cycle and monitoring threshold for the Web application, and generating a monitoring service policy according to the monitoring object, the monitoring cycle and the monitoring threshold, thereby improving the reliability of Web application performance monitoring. By performing performance monitoring on Web applications, potential performance problems can be discovered in a timely manner and prevented before the problems occur, and rich data indicators can be provided for the development team to make data-based decisions.
[0127] Figure 3 1 is a schematic diagram of the structure of a performance monitoring device for a Web application provided in an embodiment of the present application. The Web application runs on an electronic device and is developed based on the Electron framework. Figure 3 As shown, specifically including the following:
[0128] The configuration file reading module 301 is used to read the monitoring service configuration file for the Web application when the Web application is started;
[0129] A policy determination module 302, configured to determine a monitoring service policy for the Web application according to the monitoring service configuration file;
[0130] A monitoring data acquisition module 303, used to acquire device performance monitoring data when the Web application is running according to the monitoring service policy;
[0131] The monitoring result determination module 304 is used to determine the performance monitoring result of the Web application according to the device performance monitoring data.
[0132] Furthermore, the monitoring data acquisition module 303 is also used for:
[0133] Acquire page performance monitoring data when the Web application is running according to the monitoring service strategy;
[0134] Accordingly, the monitoring result determination module 304 is further used to:
[0135] The performance monitoring result of the Web application is determined according to the device performance monitoring data and / or the page performance monitoring data.
[0136] Furthermore, the device also includes:
[0137] A configuration file storage module, used for locally storing the monitoring service configuration file;
[0138] A configuration file update identification module, used to identify whether there is an update operation of the monitoring service configuration file;
[0139] The configuration file update request generating module is used to generate an update request for the monitoring service configuration file after identifying the existence of the update operation of the monitoring service configuration file, so as to synchronize the updated monitoring service configuration file to the local.
[0140] Furthermore, the strategy determination module 302 is specifically configured to:
[0141] Read the monitoring object, monitoring cycle and monitoring threshold for the Web application in the monitoring service configuration file;
[0142] A monitoring service policy is generated according to the monitoring object, the monitoring cycle and the monitoring threshold.
[0143] Furthermore, the monitoring objects include CPU data, memory data, and GC recovery data;
[0144] The monitoring data acquisition module 303 is specifically used for:
[0145] If the monitoring object is CPU data, the CPU usage rate of the Web application when it is running is obtained through the app.getAppMetrics function;
[0146] If the monitoring object is memory data, the memory occupied by the entire Web application when the Web application is running is obtained through the app.getAppMetrics function; and / or the memory occupied by each thread of the Web application when the Web application is running is obtained through the first preset interface;
[0147] If the monitoring object is GC recycling data, the number of GC recycling times when the Web application is running is obtained through a second preset interface.
[0148] Furthermore, the monitoring data acquisition module 303 is specifically used for:
[0149] The number of GC collection times when the Web application is running is monitored through the NAN_GC_CALLBACK interface of the C++ extension library of Node.js enabled when the Web application is started.
[0150] Furthermore, the strategy determination module 302 is specifically configured to:
[0151] If the monitored object is CPU data, identifying whether the CPU usage rate is continuously higher than a set usage rate threshold within a first preset time period;
[0152] If the monitoring object is memory data, identifying whether the memory occupied by the entire Web application is continuously higher than the first set memory threshold within a second preset time period; and / or identifying whether the memory occupied by each thread of the Web application is continuously higher than the second set memory threshold within the second preset time period;
[0153] If the monitoring object is GC recycling data, it is identified whether the number of GC recycling times is higher than a set recycling times threshold within a third preset time period.
[0154] The technical solution provided by the embodiment of the present application includes a configuration file reading module, which is used to read the monitoring service configuration file for the Web application when the Web application is started; a policy determination module, which is used to determine the monitoring service policy for the Web application according to the monitoring service configuration file; a monitoring data acquisition module, which is used to obtain the device performance monitoring data when the Web application is running according to the monitoring service policy; and a monitoring result determination module, which is used to determine the performance monitoring result of the Web application according to the device performance monitoring data. Through the above-mentioned performance monitoring device for Web applications, the problem that the performance monitoring is not comprehensive enough when the Web application is monitored in the related technology, and the monitoring result is not reliable enough, can be solved. By reading the monitoring service configuration file for the Web application when the Web application is started, determining the monitoring service policy, and obtaining the device performance monitoring data when the Web application is running, and determining the performance monitoring result of the Web application, the purpose of monitoring the device performance data when the Web application is running can be achieved, and the comprehensiveness of the performance monitoring of the Web application is improved. At the same time, by using different monitoring policies to monitor different performances of the Web application when it is running, the reliability of the performance monitoring of the Web application can be improved.
[0155] The performance monitoring device of the Web application in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0156] The performance monitoring device of the Web application in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0157] The performance monitoring device for a Web application provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.
[0158] Figure 4 Schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 4 As shown, the embodiment of the present application further provides an electronic device 400, including a processor 401, a memory 402, and a program or instruction stored in the memory 402 and executable on the processor 401. When the program or instruction is executed by the processor 401, each process of the above-mentioned Web application performance monitoring method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0159] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0160] The embodiment of the present application further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the embodiment of the performance monitoring method of the above-mentioned Web application is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0161] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0162] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned Web application performance monitoring method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0163] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0164] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0165] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0166] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0167] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A performance monitoring method for a Web application, characterized in that: The Web application runs on an electronic device and is developed based on an Electron framework; the method includes: When the Web application is started, reading a monitoring service configuration file for the Web application; Determining a monitoring service policy for the Web application according to the monitoring service configuration file; Acquire device performance monitoring data when the Web application is running according to the monitoring service strategy; Determine the performance monitoring result of the Web application according to the device performance monitoring data.
2. The method according to claim 1, characterized in that: After determining the monitoring service policy for the Web application according to the monitoring service configuration file, the method further includes: Acquire page performance monitoring data when the Web application is running according to the monitoring service strategy; Accordingly, determining the performance monitoring result of the Web application according to the device performance monitoring data includes: The performance monitoring result of the Web application is determined according to the device performance monitoring data and / or the page performance monitoring data.
3. The method according to claim 1, characterized in that After reading the monitoring service configuration file for the Web application, the method further includes: Locally storing the monitoring service configuration file; Identify whether there is an update operation of the monitoring service configuration file; If it exists, an update request for the monitoring service configuration file is generated to synchronize the updated monitoring service configuration file to the local computer.
4. The method according to claim 1, characterized in that: Determining a monitoring service policy for the Web application according to the monitoring service configuration file includes: Read the monitoring object, monitoring period and monitoring threshold for the Web application in the monitoring service configuration file; A monitoring service policy is generated according to the monitoring object, the monitoring cycle and the monitoring threshold.
5. The method according to claim 4, characterized in that The monitoring objects include CPU data, memory data and GC recovery data; Accordingly, obtaining device performance monitoring data when the Web application is running according to the monitoring service strategy includes: If the monitoring object is CPU data, the CPU usage rate of the Web application when it is running is obtained through the app.getAppMetrics function; If the monitoring object is memory data, the memory occupied by the entire Web application when the Web application is running is obtained through the app.getAppMetrics function; and / or the memory occupied by each thread of the Web application when the Web application is running is obtained through the first preset interface; If the monitoring object is GC recycling data, the number of GC recycling times when the Web application is running is obtained through a second preset interface.
6. The method according to claim 5, characterized in that The number of GC recycling times of the electronic device when the Web application is running is obtained through the second preset interface, including: The number of GC collection times when the Web application is running is monitored through the NAN_GC_CALLBACK interface of the C++ extension library of Node.js enabled when the Web application is started.
7. The method according to claim 4, characterized in that Generating a monitoring service strategy according to the monitoring object, the monitoring cycle, and the monitoring threshold includes: If the monitored object is CPU data, identifying whether the CPU usage rate is continuously higher than a set usage rate threshold within a first preset time period; If the monitoring object is memory data, identifying whether the memory occupied by the entire Web application is continuously higher than the first set memory threshold within a second preset time period; and / or identifying whether the memory occupied by each thread of the Web application is continuously higher than the second set memory threshold within the second preset time period; If the monitoring object is GC recycling data, it is identified whether the number of GC recycling times is higher than a set recycling times threshold within a third preset time period.
8. A performance monitoring device for a Web application, characterized in that: The web application runs on an electronic device, and the web application is developed based on the Electron framework; the device includes: A configuration file reading module, used to read a monitoring service configuration file for the Web application when the Web application is started; A policy determination module, used to determine a monitoring service policy for the Web application according to the monitoring service configuration file; A monitoring data acquisition module, used to acquire device performance monitoring data when the Web application is running according to the monitoring service strategy; The monitoring result determination module is used to determine the performance monitoring result of the Web application according to the device performance monitoring data.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method for performance monitoring of a Web application as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the performance monitoring method of a Web application according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Method for adjusting maximum heap memory of virtual machine and electronic equipment
CN120743437A