Maintenance of Java Applications with Zero Downtime in HANA Cloud Platform
While going through the Java specific release notes for HCP, I came across this article SAP HANA Cloud Platform (found via Restart your Java applications on SAP HANA Cloud Platform) which is introduced as a recommendation for additional security improvement inside the new runtime of the Java releases. Just from HCP standpoint in Productive environments (Not valid for Free Trial accounts), it can be very useful as it avoids the application downtime and still the application enhancement or changes can be made made effective in real time. Although the deployment mechanisms of applications is going to be changed with the introduction of Cloud Foundry (with much flexible command line parameters), this is still effective in classical HCP using Console Client (neo.bat/sh) when you have some business critical Java Applications running with business data.
Lately, I came across this kind of warnings as shown below, because of which I tried these steps for easy understanding.
Each application runs on one or more dedicated application processes. You can start one or many application processes at any given time, according to the compute unit quota that you have. Each process has a unique process ID that you can use to stop it. To update an application non-disruptively for users, you handle individual processes rather than the application as a whole.
Just for an example, I have my java application running in HCP and it is having an active process running as shown in the below screenshot.
The Process ID for this application is 0319318 and it is running on a compute unit of size Lite.
The procedure below describes the manual steps to execute a zero downtime update. I have tried to show each and every step with appropriate screenshots for easy references:
- Open Console Client: Open the command prompt and navigate to the folder containing neo.bat/sh (<SDK installation folder>/tools).
- Check Application status: List the status of the application which shows all its processes with their attributes (ID, status, last change date) by executing <neo status>. Identify and make a note of the application process IDs, which you will need to stop in the following steps. Application processes are listed chronologically by their last change date.
neo status –host <landscape_host> –account <account_name> –application <application_name> –user <e-mail_or_user>
- Deploy new version of the application: Deploy the new version of your application on SAP HANA Cloud Platform by executing <neo deploy> with the appropriate parameters.Note that to execute the update, you need to start one additional application process with the new version. Therefore, make sure you have configured a high enough number of maximum processes for the application (at least one higher than the number of old processes that are running). In case you have already reached the quota for your account, stop one of the already running processes, before proceeding. In this example, I have used the value as 2 processes
neo deploy –host <landscape_host> –account <account_name> –application <application_name> –source <file_location> –user <e-mail_or_user> –maximum-processes <number of maximum processes that can be started for the application>
- Start New Process: Start a new application process which is running the new version of the application by executing <neo start>.
neo start –host <landscape_host> –account <account_name> –application <application_name> –user <e-mail_or_user>
- Soft Shutdown of old process: Use soft shutdown for the application process running the old version of the application:
- Execute <neo disable> using the ID you identified in previous step. This command stops the creation of new connections to the application from new end users, but keeps the already running ones alive.
neo disable –host <landscape_host> –user <email_or_user> –application-process-id <ID>
- Wait for some time so that all working sessions finish. You can monitor user requests and used resources by configuring JMX checks, or, you can just wait for a given time period that should be enough for most of the sessions to finish.
- Stop the application process by executing <neo stop> using the <application-process-id> parameter.
neo stop –host <landscape_host> –user <email_or_user> –application-process-id <ID>
- Check Old Process Status: Make sure the application process is stopped by checking its status using the <application-process-id> parameter. As the process is stopped, this will throw error while searching the application process ID.
neo status –host <landscape_host> –user <email_or_user> –application-process-id <ID>
Although I have used these steps as per the help guide, but in real productive scenarios, where an application runs with more than one processes, this verification step is essential to make use that the updated application is correctly running with all the newly created processes.