Latest Replies
Wednesday
Aug262009

Host .NET Applications on Rackspace Cloud Servers with Mono

Let's talk about deploying .NET applications on Linux-driven Cloud Servers offered by the Rackspace ("Slicehost" and "Mosso" brands). This article would be another technological addition to xLim 4 research and development series.

Using Mono on virtual cloud server machines would allow us to run lightweight .NET application and data gateway servers (basically, your building blocks for smart enterprise applications) in a cost-effective and elastically scalable environment.

Obviously, this comes with a certain vendor lock-down at the moment, since there are not that many affordable cloud computing providers with scalable solutions (even Windows Azure does not have a scalability management API at the moment). Yet, this will change, since that's the way to make complex deployments much more flexible and cost-effective.

Cost-effectiveness comes from:

  • Decent pricing with on-demand payments for server instances.
  • Running .NET on Linux means that there are no overhead license payments (like with Windows Servers) and hardware is a lot cheaper (you can compile Mono even for the embedded devices, but I don't want to get there, yet).

Elastic scalability comes from:

  • Ability to manually resize servers on-the-fly (changing resource allocation and their prices) for basic solutions.
  • Ability to manually clone servers from a prepared image in order to handle occasional spikes or adopt for long-term usage levels (this requires development solution to be ready for such changes).
  • Ability to use REST API for automating deployment and scaling operation for creating cost-efficient solutions (as in enterprise cloud bursting solutions).

Here's the routine for building Mono 2.4.2.3 (from the latest tarball) on Linux Ubuntu x64 running on Cloud Server at Rackspace (Slicehost or Mosso):

Note 1: if you are reading this article in the year 2010, then probably you could get same accomplished by running:

apt-get install mono-xsp2

Note 2: we will be building only core Mono libraries here. Just the things that are really needed for the light-weight scalable application/gateway server in the cloud.

Note 3: no hardware was hurt in writing of this article. Approximately 12 Linux servers were deployed and killed in the research process, but this does not count, since they were purely virtual.

Step 1: Update and install core packages:

sudo apt-get update
sudo apt-get install -y build-essential bison gettext pkg-config libglib2.0-dev

Step 2: Grab and unpack Mono 2.4.2.3 tarball:

mkdir ~/download/
cd ~/download/
wget -c http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.2.3.tar.bz2

mkdir ~/build/
cd ~/build/

tar xf ~/download/mono-2.4.2.3.tar.bz2

cd mono-2.4.2.3

Step 3: Work around the bug in Linux Kernel that is currently used by Rackspace (related to amd64isimm32 assertion failure):

cd mono
cd mini
perl -i -pe 'last if eof' mini-amd64.h
perl -i -pe 'last if eof' mini-amd64.h
echo "#define MONO_ARCH_NOMAP32BIT" >> mini-amd64.h
echo "#endif" >> mini-amd64.h
cd ..
cd ..

Step 4: Optional patch - delete all 'doc' folder names in the file that is opened by the command below (mcs-docs switch does not work for some reason):

nano mcs/Makefile

Step 5: Manual patch - remove all values in 'AOT_IN_PROFILES' from file opened by the command below (Ahead-of-time compilation is not supported on our flavor of AMD64 and we are not that interested in net11 anyway):

nano mcs/class/corlib/Makefile

Step 6: Configure everything (this command is one line):

./configure --with-large-heap=yes --with-xen_opt=yes --with-mcs-docs=no \
--with-moonlight=no --enable-minimal=aot,profiler

Step 7: Make and install to the default folder:

make
sudo make install

Step 8: Verify that Mono is more-or-less working by running the command below. It should say that "No files to compile were specified".

mcs

Step 9: Optionally - get and install XPS server for running ASP.NET applications (we are interested in REST here):

cd ~/download/
wget -c http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.4.2.tar.bz2

cd ~/build/
tar xf ~/download/xsp-2.4.2.tar.bz2
cd xsp-2.4.2
./configure && make && sudo make install

Obviously, ability to run .NET code on Linux-driven and elastically resizable computing cloud does not guarantee anything. It just provides the flexible foundation for delivering building blocks of cost-efficient and scalable enterprise applications.

Simply put, it is just the beginning of research and development journey called xLim. Subscribing to the updates will keep you tuned for the news.

« Problems with Bootstrapper, WiX 3.0 and .NET 3.5 SP1 | Main | Zen Development Practices: Method-level IoC »

Reader Comments (2)

You can get mono 2.4 from this ppa:
https://launchpad.net/~mono-edge/+archive/ppa

August 26, 2009 | Unregistered CommenterAleksander Sumowski

Aleksandr, does this ppa work around Linux Kernel issues with Mono on AMD64 in virtual environment?

August 26, 2009 | Registered CommenterRinat Abdullin
Comments for this entry have been disabled. Additional comments may not be added to this entry at this time.