Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to optimize jvm and big data export report)

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This issue of the content of the editor will bring you about how to optimize jvm and big data export report optimization), the article is rich in content and professional analysis and description for you, I hope you can get something after reading this article.

Preface

Record the process of optimizing a project. It's really slow to take over. Normally, it shouldn't be so stuck. However, the specific problems have to be analyzed in the light of various environmental factors.

Front-end cache

Reason: started to optimize the project, roughly operated, found several particularly slow pages, and checked the browser's request. It is found that the amount of data requested by the two interfaces is particularly large, about 6m, 6k pieces of data, which is not used at night and needs to be requested for about half a minute to 1 minute. These two interfaces are the goods data, and the user goods are below the box. And it will be used frequently throughout the project, as a result of a large number of users, the bandwidth is dragged down and the response of other requests becomes slow.

Solution: when entering the main page after login, the goods data is directly requested and cached to the browser's sessionstorage, the goods drop-down box is modified, and the front-end cached data is used directly. After the subsequent optimization, the cache is checked when using the drop-down box, there is no request, and key is formatted to cache the corresponding data. After the optimization, it is obvious that it is not as stuttered as before, and the response speed is faster.

File export

Reason: in the middle also continue to optimize the page query and some writing, but do not have much impact. Until recently, feedback has been special card, stuck until the service is not responsive. Observed for a period of time, when stuttering, the memory of the server did not soar, but the cpu was very high. When you find that when you export excel when this happens, you get stuck and then you can't export it. When you restore the data locally, the data taken out when you get stuck is too large, about 2w, and then the data needs to be formatted into excel by poi. In this process, when the data was transferred to json for general processing, memory overflowed. Instead, it is converted directly to poi, or because the amount of data is too large and memory overflows.

Solution: there were two schemes at that time: 1 increase the memory of tomcat, and 2 do not deal with it on the server side. Well, at the beginning, I transferred the memory directly, but because of my environmental problems, I couldn't adjust it to more than 1g, so I went straight to solution 2, which converted the data to excel at the front end.

In scenario 2, in the public processing of the front-end export, get the request data to be exported, and then convert the data into table's html-"add the excel fixed header and tail tag -" and add a tag to output the file. Note that the file needs to be processed through blob or the download will fail.

The processing code is posted here.

/ * * table html code converted to excel * @ param fileName file name * @ param excel excel * / function exporExcel (fileName,excel) {/ / excel header var excelFile = ""; excelFile + =''; excelFile + =''; excelFile + = ""; excelFile + = excel; excelFile + = "; excelFile + =" / / construct a tag var uri = _ 'data:application/vnd.ms-excel;base64,', fileName = fileName | |' excelexport'; var a = document.createElement ('a'); document.body.appendChild (a); a.hreflang = 'zh'; a.charset =' utf8'; a.type = "application/vnd.ms-excel" / / js large objects to solve network errors in chrome export due to too much data (due to url length limit) var blob = new Blob ([excelFile]); a.href = URL.createObjectURL (blob); a.target ='_ blank'; a.download = fileName + '.xls'; a.tableBorder = 1; a.click (); document.body.removeChild (a);}

If the number in excel is too large and scientific calculation occurs, add style and define the format as text.

``+ value + "" +``

Plan 1: it took more than a day to adjust the memory of tomca and stepped on a lot of pits. After a long time, Baidu inadvertently came across a comment saying, is it the wrong version of my tomcat? 32 cannot exceed 1g, so it downloads a bunch of versions of tomcat. Starting with the version of tomcat-7.0.65.1 downloaded on the official website, the security check added with url cannot use characters such as | {}. After downloading 64-bit tomcat, you can add a user to tomcat-users in the conf folder, and then start tomcat. There is a manager project in his own project. You can view the running memory information and version information of tomcat, or execute the cmd command in the bin directory: version.

Confirm that you are 64-bit, if not 64-bit, 1: make sure your computer system is 64-bit 2 Note, make sure that your jdk is 64-bit jdk, it is very important. My jdk is not 64-bit, so it always shows that I am x86, so I can't adjust my memory. Also, if you are like me, your computer has 23 versions of jdk, but your environment variable has changed, and it still doesn't work, then make sure that your environment variable is modified correctly, try to bring the configuration of jdk to the front in the path environment variable, you can execute the shutdown command of tomcat, and you can show which one is used by the current jdk, if you still can't change jdk. Then modify the configuration of tomcat to use the specified jdk as I did.

Modify the catalina.bat file in the windos environment and add

Set JAVA_OPTS=-Xms800m-Xmx2048m

Restart tomcat, enter the management interface through the manager project, and check whether the modification is successful.

The above is the editor for you to share how to optimize jvm and big data export report optimization), if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report