the blog for developers

Continuous Deployment Setup at 2morethin.gs

I’ve set up continuous deployment for 2morethin.gs. Continuous deployment means that as soon as a developer finishes work, his code is pushed to the website. IMVU does it, as does WordPress.com and kaChing. This post should show you that there is no magic in continuous deployment, everyone can do it.

Why would one want to drop releases and do continuous deployments? The main benefit is that your time to market goes down drastically. Usually your time to market from idea to customer is weeks or often months. With continuous deployment it can go down to 30 minutes. This will enable your company to experiment more, take higher risks because you can change your decision in 30 minutes.

Continuous deployment setup diagram 2morethin.gs

The setup is quite easy and involves a HAProxy balancer, two Tomcats, some shell scripts, cron and Mercurial. It’s very alpha but works. I develop locally – a benefit of a distributed SCM – and when I’m done I push to the central repository. There a hook executes and writes a flagging file to /tmp. Each minute a cron job runs, checks for the file and if it’s there removes it and does a deployment. The deployment script is rather simple, it goes through the tomcats, stops each one, deploys the application and then restarts the tomcat. The HAProxy load balancer takes care of sending requests to the tomcat which is currently up, so the site does not go down during deployments.

Obviously missing currently is a test stage and roll backs if deployment on one tomcat went wrong, feedback is appreciated, leave a comment.

As continuous deployment involves a different thinking on the part of developers, testers, operators or devops, it’s better to start early with continuous deployment than later. So if you’re running a startup, do yourself a favor and use it right now.

About the author

stephan Stephan Schmidt has been working with internet technologies for the last 20 years. He was head of development, consultant and CTO and is a speaker, author and blog writer. He specializes in organizing and optimizing software development helping companies by increasing productivity with lean software development and agile methodologies. Want to know more? All views are only his own. You can find him on Google +

You can leave a Reply here. Of course, you should follow me on twitter here.

You can share this post!
Do you want to tell others about this article? Use the social bookmark icons to submit this artice to the service of your choice. Thanks.

25 Tweets

Leave a reply.

Comments

What about serious bugs? I think many people eyeing with continuous deployment shy back because the rollback might be too hard or difficult.

From what I’ve read elsewhere, people use an “immune system” (nice metaphor) to reject faulty builds from production.

It is an interesting research question to me just how that immune system could work. Ties nicely with some old work on biological framings of problems in computing and the Ultra-Large-Scale systems folks.

Dirk

Lukas

Why don’t you just let the hook trigger deploy your application? You probably need root for the deployment (especially starting and stopping tomcat) so you created the cronjob workaround, but IMHO using “setuid” on your trigger is a much cleaner solution.

@Lukas: I’m no longer a Linux Guru I was 15 years ago. That said, I had it that way first, but the push took as long as the deployment – several minutes.

With the asynchronous way of writing a flag file the push is only writing to the repository, so it’s much faster – instant.

Peritus

Next step is building a real(TM) Deployment Pipeline, with Smoketests triggering Unit Tests triggering Acceptance Tests, triggering promoted builds triggering Testers triggering Deployment ?

I’m looking forward to reading http://continuousdelivery.com/ in the late summer ..

Olivier

I wonder how do you deal with database schema upgrade? Do you run special shell scripts in this case?

@Peritus: Yes, acceptance tests + unit tests I run before push, needs to move to deployment in the future. I want to read that too :-)

@Olivier: I use Cassandra not an database with a schema. Code can deal with new (drop on write currently) and older data (default values on write).

Erik

So, how do you prevent a developer from committing something which breaks your production setup? Is automated testing, with only a deploy on success, not a minimum requirement?

I know one can test locally, but I frequently see cases where the same tests then fail on a continuous integration box because the environment was slightly different.

@Erik: You are right. This will be next. But I’m currently the only developer ;-)

“I know one can test locally, but I frequently see cases where the same tests then fail on a continuous integration box because the environment was slightly different.”

Yes this happens quite frequently.

But I guess with CD it goes down, as developers know the production environment much better than with traditional releases, testers and operators.

Oh, and there is surly a long way to IMVU or kaChing perfection

At kaChing we have sub 5 minutes commit to release. Since cron job is at least once a minute you loose in average 30 sec on deployment. Therefore we use a post commit hook to start the testing (hudson) -> deployment -> monitoring/rollback process. You can easily start a hudson job from post hook commit.

@Eishay: Thanks for the insight, I will try that next, we use hudson at my day job.

Ricardo

Interesting post. Did you consider ‘Hudson’ as your CI server to trigger deployments instead of running a cronjob to check for a file? I found the idea of using an HAproxy to skip servers while down very interesting. I imagine to tacke your deployments in stages (so at least one server is up). WIll be interested in seeing how u do rollbacks in this type of setup.

I like the idea of deploying to a new server and adding pointers to HAproxy for both the old and new servers. Rollback then becomes just reverting a pointer back (or keep both pointers) until is decided that new deployment is safe and older deployment can be deprecated. Of course this is easier to do in a cloud environment (think EC2).

@Dirk: I think concerning serious bugs only automatic testing helps.

“From what I’ve read elsewhere, people use an “immune system” (nice metaphor) to reject faulty builds from production.”

As far as I understand, the immune system is mostly for detecting CPU/memory/… anomalies in the new deployment. But of course could be used (and perhaps is) to monitor business metrics (logins/sec, checkouts/sec,…)

Interesting. I just discussed CD with a colleague and stated that I believe you can develop any site with CD. I’m curious about your progress with automated tests for smoke tests, junits and UI testing.

I’m with you on the “serious bugs need more test coverage”. And I think you have to keep in mind that you’ll develop in small steps too, so it’s harder to introduce a hidden bug that will break everything else. Having a good coverage on the code will help to find bugs even before starting the automated tests in the CD process.

Hope this post gets a 2nd part soon. ;-)

Varnish can do backend healthchecking (if configured to do so) so no need for extra proxy layer (HAProxy).

@Mikhail: Can it move hanging requests do another backend? So when one host goes down, there are no lost requests?

[...] blueprint for each table and then create as many different objects as you need in your PHP code. Code Monkeyism: Continuous Deployment Setup at 2morethin.gs Wie ein Continous Deployment Setup aussehen kann am beispiel von 2morethin.gs Writing Tests First [...]

Leave a Reply

What people wrote somewhere else:

Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

Continues Deployment without testing? awesome or something else? http://bit.ly/bV6N2U leaning towards ’something else’ #devops

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs #continuousdeployment

This comment was originally posted on Twitter

Sorry dude, but “developing locally” isn’t “a benefit of distributed SCM”. You can do that with VSS, FFS: http://bit.ly/aVtKxb

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

Stephan Schmidt: Continuous Deployment Setup at 2morethin.gs http://bit.ly/cFpIEn

This comment was originally posted on Twitter

Nice RT @codemonkeyism Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @sbtourist: Nice RT @codemonkeyism Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @ripienaar: http://bit.ly/bV6N2U leaning towards ’something else’ #devops < always with the good articles. +1

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs thanks for the kaching mention! great job

This comment was originally posted on Twitter

@mikejewell http://codemonkeyism.com/continuous-deployment-setup-2morethings/ who needs tests?

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: Continuous Deployment Setup at 2morethin.gs http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @kachingeng: RT @codemonkeyism: Just posted: “Continuous Deployment Setup at 2morethin.gs” http://bit.ly/c4ePCs

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: Continuous Deployment Setup at 2morethin.gs http://bit.ly/c4ePCs

This comment was originally posted on Twitter

Continuous Deployment Setup at 2morethin.gs http://bit.ly/aVtKxb

This comment was originally posted on Twitter

RT @mikey179: Continuous Deployment Setup at 2morethin.gs http://bit.ly/aVtKxb

This comment was originally posted on Twitter

Code Monkeyism: Continuous Deployment Setup at 2morethin.gs http://goo.gl/I9ia

This comment was originally posted on Twitter

RT @zahadumy: Code Monkeyism: Continuous Deployment Setup at 2morethin.gs http://goo.gl/I9ia

This comment was originally posted on Twitter

Additional comments powered by BackType

Guide to CodeMonkeyism

Over the last 4 years I wrote many articles on this blog. To make it easier for you to find the relevant ones, I've organized them into topics.

Top 10

6 reasons why my VC funded startup did fail

Go Ahead: Next Generation Java Programming Style

Java Interview questions: Write a String Reverser

The dark side of NoSQL

7 Bad Signs not to Work for a Software Company or Startup

Is Java dead?

Scala vs. Clojure

Never, never, never use String in Java

No future for functional programming in 2008 – Scala, F# and Nu

Clojure vs Scala, Part 2

Java Developer

Is Java Dead?

Go Ahead: Next Generation Java Programming Style

Be careful with magical code

All variables in Java must be final

Never, never, never use String in Java

Bending Java: More readable code with methods that do nothing?

NoSQL Guy

NoSQL: The Dawn of Polyglot Persistence

The dark side of NoSQL

Essential storage tradeoff: Simple Reads vs. Simple Writes

Sharding destroys the goals of your relational database

The unholy legacy of databases

Startup/CTO

Development Dream Teams

6 reasons why my VC funded startup did fail

American vs. European style of Software Development

12 Things to Reduce Your Lead Time and Time to Market

The high cost of overhead when working in parallel

Essential storage tradeoff: Simple Reads vs. Simple Writes

Job Seeker

Another Good (Java) Interview Question

7 Bad Signs not to Work for a Software Company or Startup

Java Interview questions: Write a String Reverser (and use Recursion!)

Java Interview questions: Multiple Inheritance

As a Manager: What I value in developers

Top 10 Tips (+1) to Get a Pay Raise

Agilist

What Developers Need to Know About Agile

5 Practices Better to Change in Your Scrum Implementation

Scrum is not about engineering practices

ScrumMaster and ZenMaster: The joke of certification

What is Trans-Scrum?