In this workshop you will create a Java Liberty Profile Application, import some existing code, and use the Data Cache service and the Monitoring and Analytics service from Bluemix. To get your Java Liberty Profile application up and running, you’ll need to complete the steps in Task 1 through Task 7. Contents:

Introduction

In this introduction you’ll learn important concepts and architectural considerations for using Bluemix to host a web application on the cloud.

Why deploy your application on Bluemix

There are many different types of web applications running on the Internet today. There are also just as many ways to manage and maintain the infrastructure powering those applications. IBM Bluemix delivers quick and easy cloud capabilities to deploy and maintain your web application, with minimal hassle and overhead. Applying industry-adopted standard architecture capabilities into our application deployments allow us to confidently advance and grow our infrastructure. Hosting applications on Bluemix provides users with a lot of advantages. Bluemix is an end to end offering that provides developers with a complete set of DevOps tools and integrated services to simplify development, test, build and deployment of applications. Moreover, Bluemix-hosted applications have access to the capabilities of the underlying cloud infrastructure. Such infrastructure provides the best support for non-functional requirements that are needed to support enterprise applications such as scalability, performance, availability, and security. Furthermore, Bluemix provides a rich set of services to extend your application through incorporation of sophisticated analytics, social and mobile capabilities. Finally, the Bluemix platform frees developers and organizations from worrying about infrastructure-related plumbing details and focus on what matters to their organizations – business scenarios that drive better values for their customers. The subsequent sections discuss the main considerations for deploying your web application with IBM Bluemix and provide an architecture overview. We suggest that you go through these sections first before starting on the ‘Liberty Series’ workshops.

Introduction to the Liberty web application

In the ‘Liberty Series’ workshops, you will deploy an existing web cache application, taking advantage of certain architecture elements of a web application hosting pattern, and extend it using some of the services available on Bluemix. The primary objective of extending this application’s capabilities is to showcase how a web application can scale significantly and easily by employing a set of easy to use services that are provided to you as part of Bluemix platform. We also showcase the use of third party services that are leveraged to load test the application and to showcase how scaling capabilities are reacting to load changes over time. The list of services that are used in the workshop are summarized below:
  • Data Cache: An IBM Bluemix service that supports distributed caching scenarios for web and mobile applications. The caching service uses the technology of a data grid in which you can store key-value objects. Data Cache offers a business-ready, in-memory data grid (IMDG) that places the data close to the logic and keeps it there as the business scales up.
  • Auto Scaling: In IBM Bluemix, you can automatically manage your application capacity depending on incoming loads and policies. The IBM Auto-Scaling for Bluemix service enables you to automatically increase or decrease the compute capacity of your application. The number of application instances are adjusted dynamically based on the Auto-Scaling policy you define. The service also provides metric statistics for the instances of your application. You can see the average statistics and select specific instance statistics.
  • Monitoring and Analytics: An IBM Bluemix service that provides users with the visibility and control you need over your application. Determine the response time your users see, understand the performance and availability of the application components, and leverage analytics to keep your application up and performing well. The service also provides capabilities for diagnosing problems faster by quickly identifying the root cause of application problems with line of code diagnostics. It also provides the ability to intelligently search through logs and metrics data to find the answers to applications problems.
  • Load Impact: A third party service that provides for unlimited testing, on-demand from multiple geographic locations where you can create sophisticated tests using our simple GUI or connect directly to Bluemix via our API.
As you will see in this IBM Redpaper publication, the steps required to get an existing web application to run on Bluemix are straightforward and can be completed within hours. Moreover, extending the application’s capabilities to scale is another quick exercise due to the use of existing Bluemix services. Furthermore, Bluemix enables us to deploy our application instantly to multiple environments such as test, development, pre-production and production, multiple versions or releases with agile, pipeline and DevOps-oriented integration. Finally, Bluemix provides us with the ability to integrate with on-premise enterprise resources through the built-in hybrid integration capabilities, targeting with an API or hostname and port behind our firewall! To say it simply, building our application on Bluemix enables us to grow quickly and securely, while also realizing cost & time savings, and at the same time build on industry-proven architectures.

Cloud architecture overview for web app hosting

Through this workshop series, we will incrementally grow our capabilities to adapt a standard web application into an architecture more in-line with an industry proven architecture for web application hosting. This web application hosting reference architecture (shown below) and documented at the Cloud Standards Customer Council Resource Hub, covers in detail everything from the user requesting the initial URL all the way through the backend data calls. Web application hosting reference architecture The following explains the components of the web application hosting reference architecture:
  • Inbound user requests are initially handled by Domain Name Services, which route your traffic to the proper infrastructure endpoints.
  • Content Delivery Networks provide the least latency and the highest speed to create an exceptional end user experience for all your static application content.
  • Firewalls provide a boundary to help keep intruders out while your web application operates smoothly.
  • Load Balancers allows configurability and flexibility to manage the traffic and resource usage of server nodes in your environment so that no single device gets overwhelmed.
  • The Web App Server component is the heart of your web application, serving up your core application to end users. Build your server infrastructure using high performance containers, virtual machines, or Cloud Foundry-based runtimes, all of which can be similarly integrated across the architecture.
  • The User Registry Services enable authorization and authentication to secure resources across your application.
  • Session and Data Caching ensure low latency data access and prevents data loss for a robust end-user experience. Additionally, Storage services allow you to customize and have total control over a SAN or NAS solution that fits your storage needs.
  • Managed Database Services deliver high-performance database support, while allowing you to focus on your application and not database maintenance. These databases range from standard SQL databases to newer NoSQL databases to Big Data services.
The above referenced architecture has multiple tiers and multiple components in each tier that are critical to the optimal performance of your web application. The workshops will specifically focus on the Web and Service tiers, with the Web App Server, Cache, and Load Balancer components. There are some general ground rules that are best followed when developing, deploying, and maintaining Cloud applications, in addition to the above reference architecture. These top 9 rules are covered in detail by Kyle Brown & Mike Capern in a blog post titled Top 9 rules for cloud applications, but we will review them here. First, do not code your application directly to a specific topology. As you can see here, we are only talking about components so far. There is no mention of specific hardware, software, or hosting capabilities. The key here is to keep your application flexible. The second, third and fourth rules all center around the ephemeral, or non-permanent, natures of Cloud applications. Do not assume the local file system is permanent. Do not keep session state inside your application. Do not log to the file system. Many runtimes powering Cloud applications today are ephemeral, or non-permanent. Therefore the application instances and their underlying filesystems can disappear and be rewritten when the application scales or an instance is restarted. Overall, these are not new concepts for web applications, but they are critical for successful Cloud applications. The fifth and sixth rules focus on infrastructure and what you are building your application on. Do not assume any specific infrastructure dependency. Do not use infrastructure APIs from with your application. You do not want to tie your application to the infrastructure it is running on, as it may be moved to another platform by you or the hosting provider, it may run on multiple platforms at the same time, platform APIs and dependencies change at a different lifecycle than your application code and there is no need to add another requirement. It is best practice to abstract the infrastructure needs outside of your application and handle them through management and operation interfaces available on the Cloud platform. The seventh and eighth rules are common across application development to keep your long term sanity. Do not use obscure protocols. Do not rely on Operating System-specific features. You do not know which services your application will need to integrate with in the future. You do not know which operating system your application will run on. Use as many standards-supported APIs as possible when developing your application, so as not to lock yourself into a certain runtime. Finally, the ninth rule. Do not manually install your application. Automate, automate, automate. Whether in development, test, staging, or production, you will want to automate your application installation as much as possible. This will promote reuse, save time, and vastly reduce errors in the long run. That means better application quality and more uptime for users. Hopefully, you are already adopting many of these rules in your applications today. If not, you can read Kyle & Mike’s blog post for more broader detail on what and how to accomplish these goals. The exercises we will be walking through in the workshops will exemplify these rules and demonstrate capabilities to deliver Cloud applications following them. If you’re ready to get started, lets dive into the first workshop.

Workshop tasks

Arch-Ref-Diagram-Liberty-Lab1

Task 1. Set up your Bluemix account

IBM Bluemix is an open-standards, cloud-based platform for building, managing, and running all types of applications: mobile, smart devices, web, and big data. The Bluemix capabilities include Java™, mobile back-end development, application monitoring, and features from ecosystem partners and open source, all through an as-a-service model in the cloud. Before you can use the Bluemix capabilities, you must register for an account. Sign up at no charge at and you will have a 30-day free trial. After the 30-day free trial, you will need to provide a credit card to pay as you go for your resource usage. After you sign up, you can find helpful information in the overview section of the Bluemix Docs. Note: You can run the steps listed in this workshop on any operating system you like. All you need is access to a browser and having the right set of login information on Bluemix and IBM DevOps.
  1. Log in to Bluemix. The dashboard opens as shown:
    Bluemix dashboard
    Bluemix dashboard
    The dashboard shows an overview of the active Bluemix space for your organization. By default, the space is dev and the organization is the project creator’s user name. For example, if bob@example.com logs in to Bluemix for the first time, the active space is dev and the organization is bob@example.com. If you create more organizations or spaces in Bluemix, be sure to use the same ones as you follow the tutorials. Use the default selections.

Task 2: Create your starter application on Bluemix

Given that we have a simple web application, we chose the Java Liberty profile application. The Java Liberty profile allows for runtimes that are typically built using a small footprint (< 54 MB) which provides for faster updates during builds. The Liberty profile also provides additional advantages for small memory overheads, startup times, instance creation, and easier migration for the cloud. Given that we are showcasing auto scaling that may require creating additional instances to handle potential new loads, the Liberty profile would provide great support for what we are trying to accomplish. To get started with this task, follow the next steps.
  1. Select CREATE AN APP to start your new application then select WEB.
  2. Select Liberty for Java and click CONTINUE.
  3. Name your application to Bluemix-Java-CacheLab, and click Finish . Tip: If you get an error saying “Someone already used that name”, just add your initials to this name. In that case, use this name in the instructions below instead of Bluemix-Java-CacheLab. Save this name we will be using this later.
  4. Go back to the dashboard by clicking on Back to Dashboard from the left navigation.
  5. Click on the your new application.
    Your New Application
    Your New Application
    The details window for the application opens.
    Your New Application Details
    Your New Application Details
    Notice that on the right side of the screen is the APP HEALTH section. If your application initially displays as stopped, it means that Bluemix is staging it (the status will show as Your application is staging). Wait for the status to change to Your app is running.
  6. Click on the Routes URL located just below your application name. Your shell application should now show this Hi World! screen in a new browser tab.
    Hi World!
    Hi World!
    You now have an empty Java application created in your workspace that creates a simple Hi World! message. Let’s do something interesting with it. Note: Do not close the Bluemix Dashboard tab. If you accidentally closed it, log in again to Bluemix and click on the Dashboard. Now we will need to import some code into our simple Java application that we created earlier and then use a service to make it more interesting. In order to import some code into our application, IBM uses JazzHub repository which is very similar to GitHub, but provides additional integration and build services for Bluemix. To get started with JazzHub, you need to register for a free account.

Task 3: Set up your DevOps account

IBM DevOps opens the door to a new way of working that offers faster development, without sacrificing quality or security. IBM Cloud DevOps solutions provides developers with access to all the services they need to develop and deliver innovative applications quickly. In this workshop, we will be using IBM’s DevOps services on the cloud to edit, build and deploy the code used for the sample test application. Therefore, you must have a user ID in order to access such services. To get started with this task, follow the next steps:
  1. Log into JazzHub.
  2. If you already have an IBM id click on LOG IN link on the top right. If you don’t have an IBM id click on Sign up for free and complete the required fields.

Task 4. Obtain the sample code

In the previous step we created an empty Java Liberty Profile application that does nothing interesting. In order to make this application useful, we need to import our sample application code that is available publicly on IBM’s JazzHub repository. Since you have created an IBM DevOps login in the previous steps, you can use that in this step to get access to that code. In this step, you will create a replica of the code and copy it into your local domain in JazzHub. To get started with this task, follow the next steps:
  1. Go to the URL for the sample project.
  2. Select FORK PROJECT located in the upper right corner of the screen to create your own copy of the web cache data project.
  3. You need to use the same name you gave to your Bluemix Java Liberty application to the project you create in JazzHub: Bluemix-Java-CacheLab.
    Fork Project Dialog
    Fork Project Dialog
    The following lists the settings:
    • Name your project: Bluemix-Java-CacheLab
    • Make it private: Leave it unchecked
    • Add features for Scrum development: Checked
    • Deploy to Bluemix: Checked
    • Region: Accept default
    • Organization: Select your personal organization
    • Space: Select dev
  4. Click CREATE. When the create operation is completed, you should see that your new project has been successfully created.
    New project created
    New project created
    Do not close the IBM DevOps browser page. You will need that later to edit source code and initiate build and deploy activities. If you accidentally closed the tab, login again to IBM DevOps and select the project you created to see this page again.

Task 5: Add Data Cache service

The application code that you forked in the previous step was mapped to the Java Liberty Profile starter application Bluemix-Java-CacheLab that you created earlier in See Task 2: Create your starter application on Bluemix. As part of that process, you specified the application name to be similar to the name of directory in your local domain on JazzHub. The application code that you forked assumes the use of a Data Cache service that is available from Bluemix. In this task, we will use the service catalog in Bluemix to search for the Data Cache service and bind it to our Java Liberty Profile application. Once you bind the Data Cache service, you can build and deploy the new code and you should see effect of importing the code into the Bluemix project. To get started with this task, follow the next steps:
  1. Go back to the Bluemix Dashboard tab and click on ADD A SERVICE OR API.
  2. Search for Data Cache by typing the name or parts of it in the search field.
    Search for Data Cache
    Search for Data Cache
  3. Click on the Data Cache service to open the details.
    Data Cache service details
    Data Cache service details
  4. Make sure that under App, you have the same Java application we created in this workshop selected: Bluemix-Java-CacheLab. Leave the other options as is and click CREATE.
  5. You will get a Restage Application popup. Click RESTAGE. You will get a temporary message Your application is restaging. Why restage?: Since you added a new service to a running application, you are prompted to restage the application to update it with the new service. Bluemix is trying to make sure that the application code is up to date with any changes that were applied. The Data Cache service is now created and bound to your application. The service is not ready for use yet. Each time you create a service, Bluemix creates a service name. In the application code that we imported from JazzHub, the code assumes a different service name. We need to fix that before we can put this service to good use.
  6. Go back to the Bluemix Dashboard. You should see the new Data Cache service that you created.
    Make a note of the service name
    Make a note of the service name
    You may have a different service name than what is showing in this document. Make a note of the service name since you will be using that to update a configuration file . In the context of this workshop, the service name is Data Cache-wo.
In the previous steps we managed to create a starter application, copy the sample code to use for this application, and added a Data Cache service that will be used by this application. So far, we have not initiated any step to configure, build and deploy the application in order to execute the code. Bluemix provides you with the ability to automate this process once it is configured once. In this section of the workshop, we will do the initial configuration and complete a build and deploy. Later on, this will not be required since Bluemix provides a Delivery and Pipeline service that automates all of the build and deploy activities once a successful commit and push is applied to code changes in the JazzHub repository.

Task 6: Build, deploy and run your application

We now need to configure our code to use the Data Cache service we created in the the earlier task. The name of the service in the context of this workshop is Data Cache-wo. For you, this name will be different. In order to configure the build and deploy for the first time, follow the next steps:
  1. Go to the IBM DevOps browser tab where you created your new project earlier in the workshop. If that page is closed, login to your IBM DevOps account and select the project you created for this workshop.
  2. Click EDIT CODE.
    IBM DevOps browser tab
    IBM DevOps browser tab
  3. Click the dropdown and select CREATE NEW.
    Select CREATE NEW
    Select CREATE NEW
  4. Make sure that you select the name of the application you created in the Application Name and Host fields. Click on the drop down and select your values that map to your application.
    Configure Application Deployment menu
    Configure Application Deployment menu
  5. Click the NEXT> button. In the next step, we need to make sure that our Data Cache service that we created earlier is selected in the Bound Services column on the right. Follow the steps highlighted in red and click DEPLOY when you are done.
    Follow the steps highlighted in red
    Follow the steps highlighted in red
  6. Wait until the application deploys. Once it deploys successfully, click on the arrow and notice the binding to the region and the green circle for successful deployment. Tip: Application deployment may take a couple of minutes. You will know it’s done when the popup window disappears and the green circle shows up in the app name dropdown as shown in See Application deploying.
    Application deploying
    Application deploying
  7. Go to the Bluemix Dashboard and click on your application to view the details. Click on the Routes URL. You should see the application’s screen. Try to put a value and click Put. Tip: If you cannot see the screen below, remove the cached data from your browser since it could be caching the old version of the application (Hi World).
    Application's screen
    Application’s screen
You have now successfully hosted your web application on Bluemix and it now can leverage the capabilities of the cloud to provide the best performance and scaling capabilities.

Task 7: Add Monitoring and Analytics service

The final task in this workshop is to add the Monitoring and Analytics service – an IBM Bluemix service that provides users with the visibility and control you need over your application. Determine the response time your users see, understand the performance and availability of the application components, and leverage analytics to keep your application up and performing well. The service also provides capabilities for diagnosing problems faster by quickly identifying the root cause of application problems with line of code diagnostics. It also provides the ability to intelligently search through logs and metrics data to find the answers to applications problems. Perform the following steps to add Monitoring and Analytics Service to your application:
  1. Go to your Bluemix Dashboard tab and click on ADD A SERVICE OR API.
  2. Search for Monitoring and Analytics by typing the name or parts of it in the search field.
  3. Click the Monitoring and Analytics service to open the details.
    Monitoring and Analytics - Click CREATE
    Monitoring and Analytics – Click CREATE
  4. Make sure that under App, you have the same Java application we created in this workshop selected: Bluemix-Java-CacheLab. Leave the other options as is and click CREATE.
  5. When the Restage Application popup appears, click RESTAGE.
  6. Click on the Bluemix Dashboard and then click on your application to see the latest application status.
  7. Look at the APP HEALTH. Once it shows running click on the Routes URL.
  8. Add some fields in the screen with encryption and without encryption. Tip: If you cannot see the screen below, remove the cached data from your browser since it could be caching the old version of the application (Hi World).
    Add some fields with encryption and without encryption
    Add some fields with encryption and without encryption
    Adding Monitoring and Analytics allows us to view runtime statistics about our application as we see in the subsequent steps.
  9. Return to your Bluemix Dashboard. Click the Monitoring and Analytics Service. You should see three tabs: The first tab, Availability, provides some information about the availability of the application. The second tab, Performance and Monitoring, provides information about performance of the application, and the third tab, Log Analysis, provides information about the application logs.
    Availability of the application
    Availability of the application
  10. Click on the Performance and Monitoring tab to see the performance of the application. Tip: Your results may differ from what’s shown here.
    Performance of the application
    Performance of the application
  11. Click on the Log Analysis tab to see the logs related with the application.
    Logs related with the application
    Logs related with the application
Congratulations! You have successfully created a Java Liberty Profile Application that uses the Dev Pipeline service, Data Cache and Monitoring and Analytics services. When you’re ready to learn how to add auto-scaling and load generation services to your application, you can complete Web application hosting with Auto-Scaling and Load Generation Services. Now that you’re a pro at setting up a fast and highly reliable web application that runs on the cloud, head over to Bluemix and create your own web application!

What’s next?

7 Comments on "Actionable Architecture: Web application hosting using Cloud Foundry (Liberty Workshop 1)"

  1. I think there is a missing step in this tutorial in Task 6 between Steps 6 and 7. I ended up having to open ./manifest.yml and editing the line that says:

    – Data Cache-xx

    I had to change this to whatever name was assigned to my instance of Data Cache in my Bluemix account.

    • Rick Osowski March 31, 2015

      This should be taken care of in Step 5 if you’ve walked through the Service panel and selected the appropriately mapped services. Make sure you remove the default “DataCache-iy” service instance from Bound Services and move over the “DataCache-XX” that you have listed under the Available Services. This dialog makes the change to manifest.yml in the IBM DevOps Services (IDS) web editor for you. You can then commit this change to your GIT repository from the GIT window inside IDS.

      • Seb Doncker January 08, 2016

        In my environment, the dialog step, change the file xxx.launch in the launchConfigurations folder but, as Imandres, I have to change manually the manifest.ml file with the same data (service name, host, domain, app name).
        Not a big deal but without that, the app can’t be deployed because it didn’t found the service.

        Another little difference (in January 2016), the dialog’s button is labeled “SAVE” and not “DEPLOY”. And when one click on it, the app is not redeployed. To do that, one have to click on the little arrow icon aside the dropdown.

  2. Pete Cripps May 20, 2015

    I too am struggling at Step 5. For some reason changing the bound service in the service panel to the correct one has no effect.

    • Rick Osowski June 03, 2015

      Hi Pete. Sorry for the delay in catching your comment. Are you able to proceed past step 5? I ran through the steps again, just to check to see if anything changed on the platform, and everything worked as described above for me. Let me know you’ve made progress. If not, we can figure out what the difference is.

      • Hi Rick,

        The app should be created from Bluemix DEV url: https://console.ng.bluemix.net/ . to see the Step 5 correct Data cache XX name. However after editing the deployment is taking lot of time, its more than 30 mins when I am typing this. The status says deploying.

  3. Hi Rick
    There is still a problem with the workshop. Task 6 steps 1 thru 6 do not match the screen shots in my Bluemix Environment.

Join The Discussion

Your email address will not be published. Required fields are marked *