Recent Posts

RSS Feeds

Low Cost Grails / Java Web Hosting HowTo - Part 1

Your Grails app is ready to launch?

So you created the next big web 2.0 killer app with a little help of Grails and now you want to show it to the world. A Grails web application running on your local computer is like a ship on the beach: you have to launch it into the water. How do you get it out into the rough seas of the Internet without paying to much for fuel, sailing round reefs and avoid pirates and sharks?

How do you launch it?

If you had build your web application on the basis of the Linux-Apache-Mysql-Php stack - better known as LAMP - your task would be easy and cheap: there are thousands of hosting providers waiting for you with perfectly tuned ready-to-deploy environments for ever decreasing rates.

But your Grails application is a web application running on a Java virtual machine, therefore it has almost the  same requirements like any Java web application: What you need is a computer with a Java virtual machine and Internet connection running 24/7h. But sadly enough Java web hosting has not had the same attention by hosting providers as the LAMP stacks. Java web hosting is scarce in comparison and more expensive.

The hosting alternatives

To make it worse you don't already have business plan on how to refinance your hosting costs or you want to show it off at a demo conference or your application is pro bono publico or for your local association. Therefore low cost hosting is a plus I'll discuss your alternatives:

  • Do-it-yourself local hosting with DSL connection and dynamic IP
  • Tomcat / JSP Shared Hosting
  • Virtual Root Server
  • Dedicated Root Server
  • Server-Housing / Co-Locating

DIY local hosting

Leave your web app where it is. You need a fast Internet connection via (A)DSL, ISDN oder modem dial-up won't work. Register yourself free at a dynamic IP DNS service like dyndns.com. Now as long as your computer and your web app is running, everybody on the web is able to access it.

Advantage: cheapest alternative 

Disadvantages:

  • your PC has to run night and day
  • your web app has to run night and day
  • your need a second environment for development
  • your electricity bill will raise
  • you are polluting the environment and adding to global warming

Tomcat / JSP Hosting

Search for a Tomcat / JSP hosting provider and register. Export your Grails application as a war file. Deploy it on the  remote server. Configure and test it. Let it run.

 Advantages:

  • you need no administration know-how of the operating system or the application server
  • updates of the platform will be done for you
  • mail and database are managed (in part) for you

Disadvantages:

  • you pay for the management, and since this is not mainstream like LAMP it is more expensive
  • you pay for every application
  • you pay for every database
  • your pay for other services like mail, statistics or firewall
  • there may be problems with Grails, since it's based on Groovy not Java (IBM's java virtual machine is known to have problems with Groovy unless some command line options tame the optimizations for Java)

Virtual root server 

Search for a provider of a virtual root server based on the technology like virtuozzo or OpenVZ. Pay special attention to the amount of garanteed main memory: the more the better, 256 MB being the absolut minimum but only for small apps and with lots of tweaking. Deinstall some LAMP tools to save memory, install Jetty or Tomcat, make some adjustments in Linux and deploy your Grails web app. This is not a click-and-ready solution. You have to configure some services by *gasp* vi!

Advantages:

  • very flexible
  • low cost (<10€/month with 512m RAM)
  • you pay only once and get any service out of the server that you are able to install and configure, even multiple ones
  • your may mix your Grails application with other Java applications (blogs, wikis), PHP applications (WCMS) and other open source solutions running offline in Perl or Python

Disadvantages:

  • memory is very scarce
  • cpu power is sometimes poor
  • network bandwidth and traffic are fair
  • disc space is enough
  • operation system administration is up to you
  • java app server administration is up to you
  • system security is up to you
  • spam protection is up to you and may eat your memory and cpu resources

Dedicated Root Server

This is all the same as  the virtual root server but you have enough memory and cpu resources, but at an extra price tag. You may even get managed servers where the whole upgrade of opertaion system and java platform is done my the provider. This is the right thing for companies or if your appllication has to handle  alot of traffic ( and generates income).

Advantages:

  • enough resources (memory and cpu, as much as your pay for)
  • many providers
  • some even with Java and Tomcat preinstalled
  • managed hosting an option

Disadvantages:

  • expensive (beginning with 25-50€/month, managed at ~100€/month)
  • operating system adminstration is up to you
  • same as above

Server-Housing, Co-Location

You have a second spare Computer and you search for a place in a computer center. They provide electricity and internet connection. All you have to do is get up your Grails app up and running and if it's ready you give it to the computing center.


Advantage:

  • you control the power of your server
  • enough resources
  • set it up at your home and test it before

Disadvantage:

  • you have to buy a second computer adding to your bill
  • small server are cheaper, big tower are expensive to host

My favorite alternative and proposal: the vServer

Although the vServer has some disadvantages, particularly the small memory problem, at the moment it is the alternative with the best price performance relation. Sometimes you have to digg deep in the system and need some Linux know-how to get the ship into the water, but I'll help you in the next parts of what is intended to become a tutorial for such a hosting solution. I hope this will help to bridge the gap until shared Grails/Java web hosting has become a commodity service like the LAMP offerings of today.

  Share

Permalink     Kommentare[5]

Related Articles:

Kommentare:

I like the virtual root server solution as well, though unless you're already a linux expert, configuration can suck up a lot of time!

Any recommendations of providers? I have a virtual server with rimuhosting currently -- not the cheapest out there, but solid and with good Java hosting expertise.

One thing I've noticed -- it's often damned hard to even FIND OUT how much memory your virtual server will be allocated... many hosts don't include this information on their sites.

Gesendet von Rob W am November 14, 2007 at 01:02 PM CET #

Hey Frerk
nice comparison. Now my question is whether the limited memory and cpu power is enough for a Grails app. Do you plan any real world tests?

Gesendet von Matt am November 14, 2007 at 02:28 PM CET #

@Rob W:
You're right. I can stress this. I'm Linux expert and it really take some time to get all it configure on a vServer. Therefore I decided to share my new aquired know-ledge. As soon as there is a standard hosting module for java web applications in Confixx or Plesk it will become easier for providers to host java web apps and cheaper too. I heard about some progress in this direction in Plesk.

I can't recommend vServer hosting solutions, since I'm based at germany and my best solution is not necessarily yours. But it is essential to know the minimum ram offered in advance. If it is not announced, you could select a provider with a test account and look for the pseudo file /proc/user_beancounters. privvmpages gives you the limit of memory in 4kb pages. More to come in my Part 2 posting.

@Matt:
Yes, I've benchmarked several configurations, tomcat vs jetty, java 1.4 vs. java 5 vs. java 6, etc. Please wait until my part 2 is finished. I concentrate on memory, cpu is not so critical and may be tuned by offloading static content via a front-end webserver like apache or lighttpd.

Gesendet von Frerk Meyer am November 19, 2007 at 01:14 PM CET #

most ISP's have specific clauses against serving from a home line of service. So if you intend on getting a lot of traffic, its possible you will lose your service. Otherwise, yes hosting java is expensive.

Gesendet von cease am August 01, 2008 at 09:23 PM CEST #

Good post but I'm not savvy with java setup so I have used very cheap service at http://javaprovider.net $20 bucks and groovy works fine.

Gesendet von Andrew Scoot am January 17, 2009 at 06:41 PM CET #

Senden Sie einen Kommentar:
Kommentare sind ausgeschaltet.