We have provided ‘Download Heap Dump’ hyperlink in our heap dump analysis page. When a user clicks on this hyperlink, heap dump file will be downloaded from the ycrash application to the user’s local machine. Since heap dumps tend to be a very large file, it can clog the tomcat server in which ycrash is running. To circumvent this problem, a separate web server (Apache2, nginx,… )can be installed. This web server can be used only for downloading purposes.
In this article, we will be guiding through how to download heap dump from a separate web server.
Note: In this blog we are using Apache2 web server to download heap dump. We assume that you already have Apache2 running on your desktop or server. For more information on setting up Apache2 please read the following article: How to install and configure Apache2 on Ubuntu 16.04?
Step – 1: Configure virtual host in Apache2 web server
In ycrash we have launch-yc-server.sh file. We specify -DuploadDir system property which points to the directory where all yc server artifacts are stored.
java -Xms2g -Xmx4g -DuploadDir=/opt/yc -jar webapp-runner-22.214.171.124.jar -AconnectionTimeout=3600000 --port 8080 yc.war &
Now this -DuploadDir directory should be specified as a root directory in your your-virtualhost-conf-file.conf file. Here is a sample of virtual host configuration:
<VirtualHost *:8090> ServerAdmin email@example.com ServerName your-sever-name.com ServerAlias www.your-sever-name.com DocumentRoot /opt/yc <Directory /opt/yc> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted allow from all </Directory> ErrorLog /opt/yc/error.log CustomLog /opt/yc/access.log combined </VirtualHost>
Step – 2: Configure YC server
In ycrash launch-uc-server.sh script you will need to add one more system property -DdownloadURLPrefix. This property should point to the URL of your web server.
From this point whenever the user clicks on ‘Download heap dump’ hyperlink, it will be downloaded from the web server and not from the tomcat server in which the ycrash app is running.