.NET on Cloud Foundry, Part 3: Deploying a MapReduce Application with Mono

by Alex MakarenkoSeptember 12, 2014
Learn about the potential issues the deployment may involve, as well as how to address them.

Part 1 | Part 2 | Part 3

In the previous posts, we created a MapReduce application and successfully deployed it to Cloud Foundry using Iron Foundry. This time, we will try to push it to the original Cloud Foundry using a buildpack based on Mono, an open-source framework that helps to create cross-platform .NET applications.

Although, the buildpack is currently in alpha, it provides all the features we need for the demo. For example, it runs console applications with Cloud Foundry and the lucid64 stack. This means our background worker components for mapping and reducing will most likely work. In addition, the Service Stack endpoints are fully compatible with Mono, so the Web UI component should be just fine.

 

Potential issues and solutions

Still, there are a couple of things that can interfere with deployment. First, a Reducer and a Notifier communicate via sockets, but the .NET Socket.IO Client library is not compatible with Mono, so we cannot use it.

Second, the .NET components in our solution use MongoDB capped collections for communication. Fortunately, since a Notifier is a Node.js application, we were able to add it to the same messages exchange system. This way a Reducer simply produces results without any knowledge about who will handle them and how.

The third issue concerns the Cloud Foundry router implementation, i.e., the settings for the WebSocket protocol. To get a successful handshake, we had to downgrade to XHR-polling.

 

The deployment process

The final step before deployment is updating manifest.yml with the Mono buildpack and the lucid64 stack. Once it is done, we are ready to push our .NET application to the original Cloud Foundry.

---
applications:
- name: ironic
buildpack: https://github.com/cloudfoundry-community/.net-buildpack
memory: 256MB
stack: lucid64
instances: 2
path: ./ironicweb/
services:
- mq
- name: ironicnfier
buildpack: https://github.com/cloudfoundry/heroku-buildpack-nodejs.git
memory: 256MB
instances: 1
path: ./notifier/
command: node notifier.js
services:
- mq
- name: reducer
buildpack: https://github.com/cloudfoundry-community/.net-buildpack
memory: 256MB
stack: lucid64
instances: 1
no-route: true
path: ./reducer/
services:
- mq
- name: mapper
buildpack: https://github.com/cloudfoundry-community/.net-buildpack
memory: 256MB
stack: lucid64
instances: 4
no-route: true
path: ./mapper/
services:
- mq

This is it. Now, we have two similar MapReduce apps: one deployed to Cloud Foundry with Iron Foundry and another one with Mono. However, keep it in mind that when using Mono with Cloud Foundry you are limited to components that support the Mono buildpack.

Iron Foundry and Mono are not the only tools for running .NET apps on Cloud Foundry. Other options exist, too, but they are beyond the scope of this blog post series. If you have tried running .NET apps on Cloud Foundry with Iron Foundry, Mono, or something else, feel free to share your experience in the comments.

 

Further reading


This series was written by Alex Makarenko; edited by Volha Kurylionak and Alex Khizhniak.