Wednesday, June 16, 2010

Running Your Java Web Application in Cloud --- Linux for Java Programmer (0)

Today is my birthday and I decide to do something special to celebrate: I'm going to write a series of posts about how to setup a cloud server and make your Java web application running on the Internet. It will cover the completely steps of a cloud web server's setup, including JDK, apache http server, Tomcat and MySQL database's installation in Linux. This series are most about Linux, so it can also be called as "Linux for Java programmer:)

Why Java programmers need to learn Linux?


The short answer is, Linux enables your Java Web application to say hello to the world. Your talent can be recognized and maybe your web application can be next google or twitter.

Years ago, I read a article argued why there are more web applications developed in PHP than in Java. It pointed out that the cheapest hosting price was one of main reason why PHP+MYSQL is over Java for the web applications. This is because PHP web applications only need Apache (some mods, of course) and one Linux server can host many web applications.

On the contrary, even the simplest Java web applications need JVM and Servelt container. It is hard for different web apps to share one server. So the price for Java Web applications are much higher than PHP, even ASP hosting. And their hosting is limited, sometimes you can only upload a war file. We cannot get fully control of the server. So, most of my Java web applications are shown in "http://localhost:8080/myapp". I believe there are tons of excellent web applications are buried in "localhost:8080".

Last year, my two friends and I developed a vertical Chinese search engine, based on Nutch and Lucene. Nutch is not a web application, so we cannot simply buy a Servlet container hosting. We three did all the works to make our web application served the world: we bought a Dell rack server and installed Ubuntu Linux on it. Then we installed JDK, MySQL databases, Apache Http Sever, Tomcat and connected those two servers in Linux. At last, we send this Dell server to co-location center and remotely connect it do some jobs via SSH.

We spent about $2000 for the Dell server and pay $100 to the co-location center (this is the cheapest one I found in Sydney). Things are going well, except our web application is not very successful and the high cost. Without many visitors, we didn't suffer any performance problem.


However, things changed, there are many cloud services available at very cheap price, and the same fully control as co-location server with potential scalability. I decide to have a try with the cloud server. Similar to my last search web application's journal except we don't have to buy another server. And my last experience about setting up Linux server is painful. I am a java programmer with limited Linux experience, so I did a lot of reading and search. I wish there cloud be a guide specific for tuning Linux serving Java web application. This is why I decide to write this series. Following this series, you can easily make your server running without other references.

The cloud server provider I chosen is rackspacecloud and the Linux distribution is Ubuntu Server 10.04. It's my first time to use their service so there is nothing I can guarantee. You don't have to buy a cloud server to follow this tutorials. You can just install Ubuntu on your computer and try everything with it.

0 comments: