3 Simple Steps to Deploying Artifacts in the Cloud

posted by jbrisbin on July 26, 2010 08:12 AM

You've spent a lot of time setting up a private cloud of servers. Everything's virtualized and you have it organized by function. Your messaging VMs run on these hosts and your web servers run on those hosts. You've tested it extensively and you're happy with how everything talks to each other. The worst is over, right? Wrong. Now you have to move past the theoretical and actually use this thing in production. It's time to start deploying the applications you're building into this cloud of virtualized resources. It's time to develop some scheme to keep your applications updated when changes are made. Keep in mind, whatever mistakes you inject at this point will be multiplied by the number of machines that deploys to.

Scared yet?

Don't be! It's really not that hard. In this article, I'll introduce you to some concepts I used in developing the fairly simple system of messages and scripts that deploy artifacts into our private cloud. This won't be a technical HOWTO so much as it will be a casual dinner conversation about the pitfalls and rewards. Above all, I want to get across that having a bunch of virtual machines that do the same thing doesn't have to keep you up at night.

The Security Assumptions

I don't think I've really made it a point to clarify how we handle security with an internal, private cloud. Since we don't run servers that are publicly-accessible, we can use tools that make assumptions about our environment that you likely won't be able to make if you're running the same thing on a public cloud. Our servers are protected from all external access. They are segregated onto their own VLAN. They are secured by exposing only essential ports like messaging, web, and SSH. We can get away with exposing critical system management functionality to things like messaging servers because we have other "compensating controls" in place to manage our security. Running in a public cloud opens all manner of cans of worms when it comes to security. To circumvent these entirely, we run our cloud in a private setting.

Option 1: SSH

One of the backbones of UNIX-based server clusters is SSH. It's a great tool for managing groups of servers non-interactively—assuming you have your keys exchanged properly. Our pre-cloud architecture relied on just such a system. A Subversion check-in ran a hook script that pushed changes to the application servers by running an "svn update" command on those servers via SSH. But the severe limitation here is that you have to propagate SSH keys to however many machines you want to connect to. Doing that, some might argue, isn't all that hard. I'd agree—if you're talking about doing it only once and only from one master machine to multiple slave machines. But when each server needs to potentially talk to all the other servers, propagating that many SSH keys would become, let's just say: inconvenient (I wanted to say: "a huge pain in the arse"). Beyond that, using SSH as a deployment mechanism usually means becoming a slave to Bash and being forced to learn to use Awk correctly. I'd rather have Chinese water torture.

Option 2: SCM

It makes a lot of sense to tie your deployment mechanism, in some manner or fashion, to your source code control mechanism. If you don't already have a source code control mechanism, I'd have to frankly ask: why the heck not? We used to use Subversion. Now we've switched to using Git. I love Git. It's a fantastic SCM; it's lightweight and easy to use. But the problem with using your SCM as your deployment tool is pretty obvious: I don't want stuff deployed to production every time I check something in. When we were using Subversion checkins as the deployment triggers, we would simply not check anything in until we were ready to deploy. That just doesn't work in a team environment. I can't wait until the far future deployment date to get your changes incorporated into my own work. I need those changes whenever you're finished with them. At a minimum, the SCM hook scripts can't have the final say in what gets deployed.

Option 3: Third-Party Tools

SpringSource's tcServer can be managed by Hyperic, which has an administrative function to deploy artifacts to clusters of configured servers. I don't use Hyperic, so I can't speak to the efficacy of such a solution, but I'm sure it's a viable way to manage artifact deployment—so long as all you're talking about is WAR files destined for application servers. If you also have to deploy HTML artifacts and/or configuration files with that, then you'll have to supplement the WAR file deployment with one of the other mechanisms.

Option 4: Write your Own

This is the route I took because none of the three other solutions I've mentioned here would work for me. And until private cloud architectures are a first-class citizen and have a bevy of tools that are as easy to use as "sudo gem install cloud-utils && deploy myapp.war" (I've almost got us there, the only caveat is that you have to edit a config file before running the "deploy"), you'll likely be writing something on your own. I'll help you along as much as I can, but I suspect that, given the dramatic variation in private cloud architectures, you'll still be stuck writing some custom scripts. Look at it as a learning experience—a chance to pad your resume with more cool stuff so you can finally bail when the economy picks back up, right?

Parts List: 1) A Continuous Integration Server

A Continuous Integration server is a piece of software that runs on your network somewhere and watches your source code repositories. When it sees something has been checked in, it builds your source code projects automatically. These servers also allow you to set up build dependencies so that any time a change is detected in one project, other projects that depend on it are rebuilt to make sure that the changes are compatible with those other projects. It's a huge topic and usually has more to do with testing and quality control than with artifact deployment. But we've chosen to make the CI server the focal point of our deployment methodology. There are several good OpenSource CI servers out there. CruiseControl was arguably the first, but others, namely Hudson and Apache Gump are good choices for CI as well. We use TeamCity (the free version works fine for what we need), which I like because it integrates with our IDE of choice: IntelliJ IDEA. When we push our code changes to the development server's repository, TeamCity rebuilds our projects. Part of the build process creates a couple of artifacts that need to be deployed to the various VMs—both tcServer application servers and Apache HTTPd servers. The artifacts consist of WAR files, ZIP files of configuration and definition files, and a ZIP file of the HTML, CSS, JavaScript, and sundry other static files.

When the initial build has completed successfully and all the tests have passed and all the artifacts have been built, TeamCity stages these changes immediately onto the development server. That's the only server where we actually want every change we check in to show up right away. The first half of the automated deployment process stops right here. This cycle of building source code and staging to development might happen once or it might happen a half dozen times before we've tested our changes and are ready to let them graduate to production. TeamCity has a web interface which allows the developer to simply click a button to run a build configuration. To deploy our artifacts it is, without exaggeration, as simple as clicking a button in a web page. But to do this, we need a message broker.


Parts List: 2) An Asynchronous Messaging Server

We've built some TeamCity configurations that leverage our asynchronous messaging infrastructure to notify the other servers that the artifacts it has just assembled are ready to be deployed. The reason we use a messaging broker to notify clients of deployable artifacts rather than some sort of active "scp" or "ftp" process is because the servers we might want to deploy to may not be active at the moment. By using a messaging server, we gain the ability to let the individual VMs themselves figure out whether or not they need to download the new artifact and deploy it whenever it's appropriate for that VM to do so. You probably also don't want new WAR files being deployed willy-nilly. If there's an urgent fix for some application that we need to deploy immediately, we can do so by calling the deploy script manually. But if at all possible, we let the automated process check for new deployable artifacts at 7:00 a.m. every morning. We don't have many users at that time and it's close enough to normal business hours that, if something goes horribly wrong, we can fix it without a lot of downtime between the actual deployment and when we get in of a morning. It doesn't matter all that much, of course, what messaging system you choose to perform this function. But if you've read any of my previous articles, you already know I'm a huge fan of the RabbitMQ AMQP message broker for all my messaging needs. The Ruby scripts I've written (the Gem of which is on use the Ruby AMQP client and are written against RabbitMQ 1.8. Within TeamCity, we have a build configuration which simply dumps a message into a queue. That script puts the name of the artifact in the body of the message. It's no problem to send a bunch of these. When the monitor script on the application server runs, it will only look at the last message in the queue and disregard any intervening messages.

Parts List: 3) A Messaging Client

There are two parts to deploying artifacts via RabbitMQ: the "monitor" script, which checks to see what artifacts need to be deployed, and the "deploy" script, which does the actual deployment. When we want to deploy artifacts manually, or we want to force a server to download and deploy a new artifact, we can run the "deploy" script from the command line. Otherwise, we try and let the automated processes handle it, if for no other reason than that it enforces a little bit of consistency on when artifacts get deployed. At 7:00 a.m. every morning, a cron job runs the cloud-utils' monitor script. This script reads a configuration file and, for each configured entry, checks that queue for a deployment message. Since we leave old messages on the queue for an undetermined amount of time, there might be several messages to sort through. Each deployment message contains the name of the artifact to be deployed and the MD5 sum of that artifact. Each server keeps track of which artifacts have already been deployed and will simply skip over any message it finds with one of these MD5 sums. Each monitor configuration also contains a command to run when it's been determined that a deployment artifact is ready to be deployed. If the monitor script sees a deployment message with an MD5 sum it hasn't seen yet, it will run whatever command you put in that configuration section. That said, we use the other half of the cloud-utils package: the "deploy" script. The deploy script attempts to download the artifact from the location you've configured in the deployer's configuration file. It will even go so far as to check the ETags (assuming your deployment server sends such a header) to see whether it needs to re-download that file again. If the ETag doesn't match one it has already downloaded (or you specify the "force" flag), the script will pull that artifact down over HTTP and either copy it directly to the location you specify, or (if you've configured it to do this) will attempt to unzip that downloaded file to the location you've set. It will do some rudimentary checking and try to use the "unzip" or "tar" command, depending on the file extension (".zip" or ".tar.gz", respectively). The flexibility inherent in using asynchronous messaging instead of an active SSH-based solution for deploying artifacts into your private cloud makes it worth the time it takes to set this system up. VMs don't need to share SSH keys and developers need only click a button in a web interface to deploy their artifacts into the cloud. You have better things to do than schlepp about on the command line come time to deploy your web artifacts into your private cloud.

Jon Brisbin is an Architect/Analyst/Java Guru at NPC International, the world's largest Pizza Hut franchisee. He's been deploying web applications on Tomcat for over 10 years and currently focuses on cloud computing (virtual, hybrid, and private). He built a private cloud from scratch using VMware ESX, Ubuntu Linux, packing tape, and rusty baling wire. He's done consulting work with industry leaders and Mom-and-Pops alike. Prior to NPC, Jon developed new application frameworks, integrated the AS/400 with UNIX and Windows systems, developed Lotus Domino applications, hacked websites together with Perl CGI and a text editor, and served with US Air Force Intelligence in a very hot and sandy, but undisclosed, location. He lives in the rural Midwest.

He blogs on Web 2.0 (and sundry topics) on his website:


I am very glad to read this

I am very glad to read this post regarding the easy steps to deploy artifacts in the cloud. I think this kind of information will be a great support to the users to solve the issues regarding with the software. Thank you! home care services


Software avchd converter convert avchd video files to avi, mp4, wmv, mov mod converter free download to convert HD camcorder files. mts to avi mp4 mov mkv iMovie, FCP/FCE with mts converter, so to convert mts files for your PC and mobiles.

thanks for sharing with that

thanks for sharing with that awesome articles thanks u a lot
rasoio elettrico | regolabarba | ferro da stiro con caldaia | Friggitrice ad Aria | scopa a vapore | ripetitore wifi | ripetitore wifi amplificatore wifi piastra a vapore | miglior aspirapolvere | skateboard elettrico | passeggino leggero | miglior smartphone | tablet per bambini gt-t$$

download cheat pou The most

download cheat pou The most interesting text on this interesting topic that can be found on the net ... coc juwelen hack

I'm impressed, I must say.

I'm impressed, I must say. Very rarely do I come across a blog thats both informative and entertaining, and let me tell you, you ve hit the nail on the head. Your blog is instagram followers | buy instagram likes


buy twitter followers Your own songs is actually incredible. You've a few really gifted designers. We desire a person the very best associated with achievement. youtube views

This site was... how do I say

This site was... how do I say it? Relevant!! Finally I've found something which helped me. Many thanks!
Mortgage Broker Calgary

I need to to thank you for

I need to to thank you for this good read!! I definitely loved every little bit of it. I have you bookmarked to look at new stuff you post…
Edmonton Mortgage Broker
Life Insurance Vancouver
Life Insurance Calgary


This is something that shall be really interesting. I would like to try it out on my own too. Is there anything that I should be careful about when doing this without any support from a professional ? if so please point out the same. directv


how to get more favorites and retweets on twitter These things are very important, good think so - I think so too... twitter followers buy

Profit primarily prime

Profit primarily prime quality items -- you can understand them all within: plastic dishes that look like china

Feeling good to know such

Feeling good to know such easy steps to Deploy Artifacts in the Cloud as I am working with cloud management now. We used to follow a more complicated method till now to do the deployment, but your idea seems to be more simple and easy to film makeup artist follow. Thanks for sharing.

I have express a few of the

I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…

Welcome to the party of my

Welcome to the party of my life here you will learn everything about me.

It is especially decent,

It is especially decent, though look into the tips during this home address. Tour du lịch đảo Lý Sơn

Acknowledges for paper such a

Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription... girlfriend system christian h.

I read this article. I think

I read this article. I think You put a great deal of exertion to make this article. I like your work. Gclub

This is helpful, nonetheless

This is helpful, nonetheless it can be crucial so that you can check out the following website: visit our website

Your texts on this subject

Your texts on this subject are correct, see how I wrote this site is really very good. Export News in India

Profit primarily prime

Profit primarily prime quality items -- you can understand them all within: Edinburgh

This is important, though

This is important, though it's necessary to help you head over to it weblink: buy web traffic

Your blogs further more each

Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. off page seo

There you can download for

There you can download for free, see the first of these data. china sourcing

For true fans of this thread

For true fans of this thread I will address is a free online!, fest

I am very happy with the

I am very happy with the Apache Tomcat new version that is released now. After installing this, I found it gives a very good interface and a better performance when compare with the previous versions released yet. I am glad to be aware about all new features desc here.
professional photo editing service

Hi there...

just turned into aware of your blog through Google, and located that it's truly informative. I am going to watch out for brussels. I will be grateful in case you proceed this in future. Numerous other people shall be benefited out of your writing. Cheers!
Visit Our Site At: Davie Locksmith - Locksmith Davie - Emergency Davie Locksmith - Commercial Davie Locksmith - Residential Davie Locksmith - Automotive Davie Locksmith for all your locksmith needs

Davie Locskmith

Davie Locksmith<


hi, i really enjoy your article
it was great article. it would be great if you read my article about iran automotive industry.
Iran Automotive Industry


When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks! obat untuk asma


I am glad to read this
whatsapp web
whatsapp for iphone

Check Cashing Costa-mesa

Seriously, What Fantastic write-up! I settled that associate excessive quantity info. I would adore assisting advocate folks of that you wish to carry giving like kind of facts. At now merely click here Check Cashing Costa-mesa Appreciate it for excellent task.

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.