Journey to Bluemix: Part 3 - Deploying without Downtime

Once you have gone through the trouble of setting up your static website on Bluemix and done up a custom domain for your application, you’ll need to start doing updates. If you follow the instructions from the previous post about getting started on Bluemix, you’ll see that you have downtime every time you do an update. When you do a cf push, your website might go offline for about 60 – 75 seconds.

So, let’s now try to see how we could get deployments done without any down time. This is something that Bluemix makes simple… and when I say simple, I mean really, really simple!

What we need to do:

  1. Rename our old application to a different name
    • You know that doing cf push uses your manifest.yml and pushes to the same instance of the application that you’re running. So, the first thing you need to do is to rename your current application on Bluemix. From the command line, do the following:
      cf rename current-app app-old
  2. Check your apps once to be sure
    • You can see all your apps from the command line by doing:
      cf apps
    • This will help you confirm that the app has been renamed but is still tied to the same old URLs and custom domains as you had set up – your site is still online (head on over to the website and check if you’re in doubt).
  3. Push the updated version and let it start as another instance
    • When your site is ready, just do:
      cf push
    • Once the push is completed, you’ll see 2 instances running when you check:
      cf apps
  4. Look at the routes
    • You’ll see that the new instance is probably not connected to the custom domain you had set up. You’ll have to map that route in by doing:
      cf map-route onghu-blog your.custom.domain
    • You might get a note that the route exists (since you’ve created it before) but it will map it to the new instance now. You can verify that by doing cf apps once again.
  5. You’re now ready to retire the old instance
    • You can stop the old instance by doing:
      cf stop app-old
    • You’ll see that the site is still online since Bluemix has been happily routing requests to the other instance also. If you want, you can delete the old application altogether by doing:
      cf delete app-old

That’s really all there is to it!

Recommended Reading

The Bluemix page about updating applications is extremely well written and has instructions that are very accurate and easy to follow. It has some more details also.

comments powered by Disqus