Showing posts with label AppFog. Show all posts
Showing posts with label AppFog. Show all posts

Saturday, February 16, 2013

Hosted MongoDB connection problems

Just a quick story/solution today so that I don't completely neglect this blog. I recently changed a little project from using Azure to using AppFog, and everything was going fine until I started having some random connection issues with MongoDB. After deployment everything would work fine for a while, but then a few minutes later I wouldn't be able to connect the the database and I just got a random error or timeout.

After scratching my head for a while, Googling around for a solution, and changing my DB layer implementation a few times, I was out of ideas. Then I started to look into my configuration. I have my DB hosted at mongolab and I hadn't updated the hosting location - it was still hosted on Azure, but my AppFog site was hosted on AWS. I didn't think this would be a problem, but I cloned my DB and hosted it on AWS, and then everything started working perfectly.

So if anyone happens to have this problem, and you somehow manage to end up at this site - just make sure that your DB is hosted at the same place as your app.

Monday, December 31, 2012

TypeScript Node.js Development Part 6 - AppFog Deployment

It's been a long and exciting journey, but we now have a pretty good foundation of a Node.js app, tested and debuggable, deployed to Azure. That's great, but I quickly ran into a problem. Apparently the way that Azure Web Site processes are handled means that long-running processes are not allowed, and are automatically killed after about half an hour. What I was trying to write required a timer going off at a certain interval indefinitely, but there was just no way to get this to work in an Azure Web Site. My only option if I was going to stick with Azure was to use a Cloud Service rather than a Web Site, but that would take me out of the free tier, which is quite unacceptable.

After a bit of searching around, I found out about a service called AppFog. AppFog is a "Platform as a Service" or PaaS provider, which basically means that, like Azure, they take out all the hassle of deploying code to "The Cloud". The way it works is simple, you sign up for an account, and create an app by choosing from a template (Node app, etc) and a hosting provider (AWS, etc). Behind the scenes, AppFog will provision the host and deploy the template code and in minutes you'll have a skeleton website ready to go. And best of all there is a generous free tier.

Once set up, all you need to do is download the template source code from the AppFog console, overwrite it with the code that we've been using in Azure, update the environment variables again using the console, then upload the code using a few simple commands:
gem install af
af login
af update [sitename]

There isn't the nice git integration and ability to view and rollback deployments like in Azure, but it does allow long-running processes, and it seems to be a bit easier to use and much more adaptable than Azure.

And I'll leave this series of posts at that, hopefully someone has learned something from all this and decides to give TypeScript Node.js development a go, it's been fun!

Previously: TypeScript Node.js Development Part 5 - Unit Tests and Debugging.