.NET on Cloud Foundry, Part 3: Deploying a MapReduce Application with Mono
Part 1 | Part 2 | Part 3
In the previous posts, we created a MapReduce application and successfully deployed it to CF 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:
1. First, Reducer and Notifier communicate via sockets, but the .NET SocketIOClient library is not compatible with Mono, so we cannot use it.
2. Second, the .NET components in our solution use MongoDB capped collections for communication. Fortunately, since Notifier is a NodeJS application, I was able to add it to the same messages exchange system. This way Reducer simply produces results without any knowledge about who will handle them and how.
3. The third issue concerns the Cloud Foundry router implementation, i.e. the settings for the Web sockets protocol. To get a successful handshake, I 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 CF with Iron Foundry and another one with Mono. However, keep it in mind that when using Mono with CF 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 CF with Iron Foundry, Mono, or something else, feel free to share your experience in the comments.
- .NET on Cloud Foundry, Part 1: Installing Cloud Foundry on Windows
- .NET on Cloud Foundry, Part 2: Prototyping with Iron Foundry
- 2.1 Hosting web applications on Iron Foundry
- 2.2 Enabling messaging on Iron Foundry using MongoDB capped collections
- 2.3 Implementing a notifier with WebSockets
- 2.4 Assembling a test app for Iron Foundry
- 2.5 Implementing a word search algorithm in Iron Foundry using MapReduce
- 2.6 Deploying applications to Iron Foundry
- 2.7 Validating a prototype in Iron Foundry