More Clojure deployment options

I have been very happy running multiple Clojure web apps using the embedded Jetty server using lein trampoline on a large VPS. I start each app on a different port and use nginx to map to each app to its own domain name. Easy and this lets me also adjust the JVM memory individually for each application. This works so well for me that I almost feel guilty trying alternatives :-)

I don't know if I will permanently change my deployment strategy but I am experimenting using Immutant which is a Clojure deployment platform built on top of JBoss AS 7. After installing the lein Immutant plugin and the latest version of Immutant, then you can run the JBoss AS/Immutant using lein, and separately deploy and un-deploy web applications using lein. Pretty slick, but I am still trying to get a grip on interactive development by connecting nREPL (documentation: Interactive development). My usual style of interactive development is pretty nice (I use IntelliJ to edit, keep the web app running with lein run with live loading of changes to Clojure code (including Hiccup, which is my favorite ""markup""), CSS, etc. I am going to give Immutant with nREPL interactive development a long and patient try - not sure what I will be using a month from now: probably not because I prefer stacks that are less complicated. My days of loving heavy weight J2EE apps are over :-)

BTW, I would bet that many of us have suffered a little using a do-it-yourself custom cartridge on Red Hat's OpenShift PaaS. It works, but at least for me, it was painful even with a lot of useful material on the web describing how to do it. This Immuntant based example looks more promising.

I have used Heroku in the past for Clojure web apps but since I usually have 3 or 4 distinct web apps deployed the cost of about $35 each is much more than putting them all on a large memory multiple core VPS. I very much wish that Heroku had a slightly less expensive paid 1 dyno plan that never gets swapped out when idle, causing a loading request delay.

I haven't yet tried Jelastic hosting. Their minimum paid plan with 128MB RAM (that I assume would always be active, so no loading request delays) is about $15/month which sounds fair enough. They deserve a try in the near future :-)

Another option that I have used for both one of my Clojure web apps and a low traffic web app for a customer is to pre-pay for a micro EC2 instance for a monthly cost of about $5. My only problem with this is that EC2 instances are not so reliable, and I feel like I am better off with a quality VPS hosting company. BTW, if you run a Clojure web app using the embedded Jetty server on a micro EC2, be sure you run it using "nice" to lower its priority and avoid AWS drastically reducing your resources because you use too much CPU time for too long of a period; I find much better continuous performance using "nice" - go figure that one out!

One AWS option I haven't tried yet is using lein-beanstalk which looks good from the documentation. Elastic Load Balancing on AWS costs about $18/month which drives up the cost of a Elastic Beanstalk deployment of a low traffic web app, but I think it does offer resilience to failing EC2s. You are limited to one web app per Elastic Beanstalk deployment, so this is really only a good option for a high traffic app.

A few years ago I also used appengine-magic for hosting on GAE but it bothers me that apps are not easily portable to other deployment platforms, especially converting datastore code. This is too bad because when Google raised prices and brought AppEngine out of beta, that made it more attractive to me, even with some developers complaining of large costs increases. Still, for my desire for a robust and inexpensive hosting for low or medium traffic web sites, AppEngine is in the running by simply setting the minimum number of idle instances to 1 and the maximum number of instances to 1: that should handle modest traffic for about $10/month with (hopefully) no loading request delays.

Edit: someone at my VPS hosting company (RimuHosting) just told me that as long as I set up all my apps, nginx, etc. to automatically start when a system is rebooted, then I probably have no worries: on any hardware problems they restart from a backup on a new physical server. I do occasionally try a soft-reboot of my VPS just to make sure everything gets started properly. I thought that RimuHosting would do this, but I asked to make sure.

Edit: the New York Times has a good article on the big business of offering cloud services that is worth reading:

Edit: 2013-03-14: Jim Crossley set up a demo project that exercises using the common services for Immuntant/JBoss, and wraps project source and resource files for live loading of changes to Clojure code and resources: Immutant demo.


  1. Hi Mark,

    We appreciate the feedback on Immutant and want very much to get its interactive development experience polished. I was curious which version you're using, because I only recently committed some auto-reloading changes you may want to try. They should be included in incremental build 789 or later. If yours is older than that, run 'lein immutant install' to pick up the latest. Please drop in #immutant on freenode if you need some quick answers to anything.


    The relevant change:

    Our builds page:

  2. Jim, thanks for the information!

    I just did the Installation via lein so I didn't pick up the latest builds.

    My interest in Immutant being able to have some services like AWS provides, (but without using AWS) like durable asynchronous message queues, and to be able to build systems with modular application services.

    I really like AWS as a platform but after years of using AWS I think that for systems that don't have to easily scale, then VPS (or physical server) hosting gives a lot more resources for one's money (e.g.,

    I just followed you on Twitter and I will email you if I have any specific questions.

  3. Jim, a correction. I did get the latest build:

  4. Mark, exactly which incremental version you get when you download LATEST depends on when you download it. :)

    When you unzip it, the top level directory should indicate the actual number, which is 794 right now. If you use the plugin to install, look at which release the ~/.lein/immutant/current symlink is pointing to.

    Once we confirm that you're using an incremental newer than 789 and you're still having trouble, can you file a jira with steps to reproduce, please?

    Thanks again,

  5. Darn. :)

    I'd like to create a jira to track it. If you'd rather not do it, email me the details and I will.


  6. I just sent you an email with a little hack for getting reloading working for me.

  7. Hi - I looked at Amazon, Google, and Red Hat but they all looked like a lot of set-up time & reading were needed. Before I got any of them working, I read that James Gosling had praised Jelastic so I looked it up. They have a very simple deployment model (effortless!), and you can even try it out with their own demo "Hello World" webapp right on the spot (or upload your own jar using git).
    Alan Thompson

  8. Thanks Alan, I definitely have Jelastic on "my list." It looks like it costs about $15/month to host a small application. That is reasonable as long as apps always stay loaded (I.e., there is no loading request time because an app has been deactivated.)


Post a Comment

Popular posts from this blog

Ruby Sinatra web apps with background work threads

My Dad's work with Robert Oppenheimer and Edward Teller

Time and Attention Fragmentation in Our Digital Lives