The Fastest Way to Deploy Clojure Applications to the Cloud

Clojure is a rather recently developed language, a dialect of Lisp targeted for the JVM. It came on the scene back in 2007 and has gained a loyal following due to the numerous advantages that it offers developers, especially how it simplifies multi-threaded programming.

Clojure on the Jelastic Cloud

Clojure is a functional, general-purpose, compiled language. It is complied directly to JVM bytecode, but remains completely dynamic. Every feature supported by Clojure is supported at runtime. It also provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection. With Jelastic, you can take advantage of all the benefits of coding with Clojure without the limitations placed on you with other platforms like AWS Elastic Beanstalk (Elastic Beanstalk), Google App Engine (GAE), Microsoft Windows Azure (Azure) or Heroku.

Advantages of Coding in Clojure

  • Suited for highly-concurrent applications
  • All the benefits of functional programming without all the negatives associated with the imperative approach
  • Allows dynamic, compact code with late binding, macros and multi-methods
  • Can code functions to sequence abstraction instead of to specific data structures
  • Supports Lazy sequences
  • And probably most importantly, it runs on the JVM: highly portable and fast garbage collection

Business/Cost Benefits of Using Clojure and Jelastic

The growing complexity of languages and the needs of customers threatens to overwhelm today’s programmer. Clojure was made/designed to help alleviate the load placed placed on the developer, because it is all too easy to get caught up focusing on details and handling specific issues related to new technology and forgetting the big picture, i.e. missing the forest for the trees.

Cost/Business Benefits of Using Clojure

Clojure provides many benefits to the developer, especially those that are working on highly-concurrent applications. Though it may be a rather specific target group, there is a huge amount of work that is being done with Clojure because of how well it is suited for this kind of programming.

  • Clojure was built to be simple
  • “Code is Data”
  • Easy to write and test functions
  • Data is immutable
  • States are explicit
  • Built on JVM
    • Most widely used development platform today: portability and interoperability
    • Clojure provides fast, wrappers free access to Java code
  • Built for multi-threaded applications: simplifies multi-threaded programming
Cost/Business Benefits of Using Deploying Clojure with Jelastic
Jelastic was made with the developer and businessman in mind, because in our world, those two are many times one and the same. If you are using Clojure, Jelastic should be the platform you are using to deploy your applications because:
  • Jelastic is the fastest and most efficient way to deploy Clojure applications
  • Unlike GAE (used by many developers to deploy their Clojure apps), Jelastic actually supports multi-threaded applications: if you are doing multi-threaded programming, you need your platform to support it – Jelastic does
  • No restrictions: any multi-threaded application or library is supported
  • Scale your application up and down, automatically
    • You need more processing power? You got it. Automatically
    • Want to reduce cost and save some money? You got it. Automatically
  • Ability to backup, replicate or simply copy your application across a global network of hosting service providers easily
  • No lock-in: want to host your application in Europe or US? Or do you need to have your application hosted in the US, Japan and Russia at the same time? Done
  • No need for a system administrator: save your money – with Jelastic there is no need for a sys admin
  • No learning curve: unlike Amazon, Google or Microsoft, with Jelastic you don’t have to spend valuable time (and money) learning how the platform works, reading up on the limitations that are placed on your app, learning about their custom app servers and databases or recoding your app to make it work – with Jelastic you can be running in minutes instead of hours

Deploying Your Clojure App to the Cloud

The instruction below show you how to deploy Clojure applications to Jelastic using the Maven build node. It’s super easy and you can be up and running in no time.

Create the environment

1. Go to jelastic.com and sign up if you haven’t done it yet or log in with your Jelastic credentials by clicking the Sign In link on the page.

2. Ask Jelastic to create a new environment.

3. In the Environment topology dialog which opens, pick Tomcat 6 as your application server and Maven as your building tool, type your environment name, for example, clojureapp and click Create.

In just a minute the environment with both Tomcat and Maven will be created.

Build and deploy the project

1. Click on Add project button for Maven.

2. In the dialog, navigate to the Git tab (or SVN). Specify your project name, Path to your project, Branch, Login and Password of your repository, name of your Environment, Context in which you will deploy your project, and click Add. We’ll use a simple Clojure application as an example. You can find this project here.

Now your project is successfully added.

3. Click on the Build and deploy button for your project.

This process will take a few minutes. Your project will appear in the context that you have specified and in the Deployment Manager.

That’s all you have to do! Now you can open your Clojure application in a web browser and enjoy.

3 Responses to “The Fastest Way to Deploy Clojure Applications to the Cloud”

  1. Arthur Edelstein

    These days, almost everyone programming in clojure uses the lein (leiningen) build tool [1]. While lein uses Maven under the hood, the pom.xml (Maven) file lein generates doesn’t seem to be compatible with Jelastic.

    But there is a simple way to get lein-based projects to run on Jelastic. I tried this with an example from the compojure project [2]:

    1. Make sure lein and lein-ring [3] are installed.
    2. Type the following:
    git clone https://github.com/weavejester/compojure-example.git
    cd compojure-example
    lein deps
    lein uberwar
    3. Upload the resulting war file, located in the compojure-example/target directory, to Jelastic, and deploy it on a Tomcat instance (Maven is not required).
    4. Once the site is running, click the “open in browser” button.

    Note that this war file contains an embedded css file — you can browse to it at http://the server domain]/css/style.css . In general, static html, css, javascript, images, and image files can be embedded as “resource files” in the war file — the compojure-example source code [2] shows how.

    [1] https://github.com/technomancy/leiningen
    [2] https://github.com/arthuredelstein/compojure-example
    [3] https://github.com/weavejester/lein-ring/

    Reply

Leave a Reply