typemismatch

just a projection of my own imagination

  • You are here: 
  • Home
  • 2009 June

Don’t go Mono, go Ruby …

Posted on June 27th, 2009

I’ve always liked the Mono project and since its inception way back when I’ve dabbled with their technology. The thought of running .NET on linux was something I always wanted to do. Recently I had a real business need to have parts of an application run on UBuntu. Not only that but I hear plenty of clients make the wild claim that “hey, if we need to run on linux we’ll just use mono!”

Initially I looked at doing this in Ruby but the learning curve for my back end services was a little steep. No problem, I’ll keep development moving in C# but keep it simple 2.0 so that it can run on Mono. Over the last few days I setup some new UBuntu servers and tried to get some of these applications running. No luck. I even ran the analyser tool which tries to make sure everything is compatible… it was. All the calls I use are available in Mono but the results are different.

That alone is high risk. If I’m using the same basic calls then I really need the results to be the same on each platform. It then occurred to me that the entire principle of the Mono project is doomed to fail. It is and always will be a sub-par port of .NET.

The bottom line is, if you want or need your application to truly run cross platform then use a language with native support, from the beginning for those needs. There are many. You have choices like Java, Python or Ruby just to name some. C# for the time being is a Windows language.

I have chosen to slowly convert rather than port and will run back ground services as Ruby apps which once written in Ruby run anywhere Ruby is supported without problems. My websites however will remain asp.net mvc. I have had plenty of success with Rails but the new MVC for .NET is just too good :)

Just a side note: I’m sure plenty of applications can be built in Mono but they need to be built and tested in Mono from the beginning. The problem you’ll run into is many c# 3rd party components, if not most, are written and tested in .NET and you don’t really know if they’ll work on Mono. Again here I say – if you only use Mono fine but why not rather use a true cross platform technology rather than a continuous port.

Tags:
Filed under .NET, Software | No Comments »

Going live with Windows Azure

Posted on June 8th, 2009

So of course you’re only going to do this if you’re nuts … right? Remember that I never said I wasn’t!

Here is the application that I needed to host. In my mind a perfect candidate for a compute cloud. It is basically a second stage monitoring service. I have various services deployed in other data centers. If one fails or goes offline the server it is on will restart it. (Stage 1) – but what if the entire server is down? This is my second service, every few minutes it checks data in the cloud (AMZ) for last contact times from a bunch of services. If anything has checked in within 5 minutes … bamb! I get some critical email warnings.

The application consisted of a Worker Role that does the monitoring and then a Web Role. This is used to expose a REST API to my mobile applications so that status information can also be pulled at any time. Due to the 1 project limit currently on Azure I bundled these two roles into one package.

Deployment was a snap. Just upload the package and configuration files and it hits staging without issue. Azure allows a staging to production promotion which is great. I hit the promote and then run buttons and all was well – the service deployed and run without issue.

It has been running without any noticed downtime for a few days now. Today a service outside Azure happened to fail and I received my email, awesome. Some notes about Azure so far:

  • The only errors always seem to be from the actual web admin tool. You get the usual MS generic error and you have just try again.
  • On one occasion the application said it was promoted to production and running but the DNS for the Web Role failed to register.
  • The web admin site is too slow.

That is all for now. Next I’ll be testing the data services! I love Amazon’s high speed de-normalized database so looking for something similar.

Tags: ,
Filed under General | No Comments »

Watch your time zones on Windows Azure!

Posted on June 8th, 2009

So I deployed some code to Windows Azure and was initially surprised that it was running differently than what I had observed locally.

Turns out and once you think of it its a no brainer … my code was running in a different time zone. All my other services were in EST but this was PST. The solution in my case is to keep everything as GMT and then do any necessary calculations :)

You might wonder if this is documented anywhere. To be honest, I have no idea since most of the documentation has been very poor. The website for Azure has circular links that will drive you nuts and the local SDK docs are just focused more on the API and are too incomplete as well.

Update: Since posting I’ve been told all servers will be and are currently in GMT time. Cool!

Tags:
Filed under Software | 3 Comments »

Deployment to Windows Azure

Posted on June 4th, 2009

Here goes my first real deployment. The first thing you’ll notice is that you no longer need an application id. It looks like that was there for live authentication and so it has been decoupled for those not needing it by default.

To deploy you just upload the application package and service configuration file. By the way, just right click your worker role project and pick Publish to generate your files. Once uploaded, you get this cool staging/production screen.

image

Once uploaded you can change the configuration xml via the browser which is great! I’m about the hit run and see what happens …

Staging worked perfectly. I can’t find a way to view logs so I’m going to promote it to production next. As a test the service emails me the logs, so I can see it all working.

The promotion seemed to work however I did get a system error from the website. I will say this – the site needs some work, it is pretty slow and bulky. Come on MS make it fly! :)

Tags:
Filed under Software | No Comments »

Using Windows Azure with Amazon Simple DB

Posted on June 4th, 2009

I have a great real world example of something that needs to be run in the cloud. Currently I have 2 types of applications running. One type is a sentinel and the other is a listener. There are many of these running today across three data centers. I want to know when one of these services has stopped functioning correctly.

My test is going to be to build a worker role that can run in Azure, connect to Amazon’s Simple DB service and look for status information sent from these other services. This will show connectivity between two different cloud technologies and allow me to test the availability and notification services of Azure. For example, is this new worker goes offline – how do I get notified?

I’ll be using my SDB .NET Provider which I haven’t yet released to the public. It allows me to hide the implementation of the Simple DB code so I can switch it out as required. It includes all Amazon libraries as well as SQS and a .NET Membership provider.

Here is the initial code block.

image

We’ll write an object to Amazon and then see if we can fetch it. This is making use of Amazon’s web services. I specifically didn’t put any exception handling around this start method because I want to see what the Azure system does when something goes wrong. The provider was configured using an app.config file.

When I tried to run – problem:

System.Security.SecurityException Message=Request for ConfigurationPermission failed while attempting to access configuration section at …. – lucky for me controlling the section permissions can be done in the config file. I set my section to requirePermission=false.

I don’t seem to be able to use a config file to setup the provider so I’m going to cheat for now and setup a stand alone instance without any config files and we’ll see how that does :) I did notice I’m probably supposed to put all the required config xml in the service configuration file so I’ll do that next time.

Here is a screenshot of the output, works like a charm. A test object was written and retrieved from Amazon Simple DB.

image

A couple notes. If you rename your worker role don’t forget to update your service definition file and configuration file. There does appear to be a problem with the developer fabric. I write information event entries to the log and they were not showing up but I knew the role was running. After restarting the fabric the messages started to appear again so I’ll see if I can report that as an issue. As an FYI I used a System Timer object to trigger my code, works great too.

In my next post, I’ll try deploy this to the real cloud :)

Tags: ,
Filed under Software | No Comments »

My TDD Analogy

Posted on June 3rd, 2009

In my post about Test Driven Design I expressed concerns around building your entire architecture to just support testing. My thoughts were definately tough to put into words, maybe I should have used more pictures :)

I do finally feel I have a decent analogy to the problem I’m concerned with. Building your application to be perfectly testable would be like building a car to always pass a crash test and to say – “let’s build a car that could never ever hurt someone”. Great, so it has no wheels or even an engine but dammit, it performs great in crash tests, it passes every test!

Applications have to work, testing like vehicle safety does unfortunately come second to functionality. Should you test? of course – but it is a balancing act so don’t get sucked into all the hype.

Also, in the words of Jeff Atwood, don’t just listen to me or don’t listen to me at all. I am no expert so do your homework :)

Tags:
Filed under Software | No Comments »

Windows 7 RC on Apple Mac Hardware

Posted on June 2nd, 2009

I still love all my MAC hardware but when doing a lot of heavy .NET development on my mac book pro I wish I didn’t always have to virtualize the environment.

Firstly, running Windows 7 RC in Vmware’s Fusion is great. It is fast, stable and generally a total turn around from Vista. I do however want the maximum out of my hardware so decided to try Windows without the virtual machine.

To do this I went away from the suggested Bootcamp installation since I had a bunch of spare, high speed SATA drives I threw on of those in and was off. The boot sequence on these machines is great, I just selected the Win 7 installer DVD and installed to the empty drive.

Once up and running I had to get some new drivers from Apple and install the Windows version of Bootcamp which helps with drivers, mouse support etc. Once I had all the drivers installed and rebooted I ran the test to figure out my machine’s rating. It scored a fantastic 5.7!! and before I had a 1.0 under fusion.

I still think Apple has the best hardware money can buy and would definately recommened buying their hardware and once Windows 7 is released, installing and using that. It is so fast, stable and great looking that it will blow you away.

Tags: ,
Filed under Electronics | No Comments »

First Azure Worker Role

Posted on June 1st, 2009

Here are some of my findings around Microsoft’s upcoming Azure platform. I initially thought Amazon had it in the bag with EC2 but to be honest, I’m tired of running my own servers. Google’s app hosting is ok, if you like Java or Python technologies – which I do but I thought I’d try the full Visual Studio approach :)

I’m using Visual Studio 2010 Beta 1. First gotcha, I wanted to run my work role and was told I had to be running VS as administrator … boo really? Wasn’t that a freaking Vista problem. This is Windows 7 RC1 people!

image

If you’re not running SQL Express you’ll need to reconfigure the local data storage services, which have those lovely hidden options buried in a .config file. Thanks to the link for the location. (Changing Development Storage)

Get it right and you’ll get this nice little local storage window the first time you run something:

image

When your role gets running, you can load up the fabric UI to actually get control of your own Azure cloud. All this without having to actually deploy to the cloud yet. Pretty neat. Remember that a role is basically like a console application in the cloud. Here is my little default application running, the output is just like a console window:

image 

So what comes next? I’m going to try embed my Amazon Simple DB provider and S3 library into a real role and throw in some workflow for fun. Might as well push it right :) I’ll also be fetching some data from AQS. (Amazon Queue Service). I’ve read a fair bit about thread issues or at least limits on how many instances of a role can run.

Right now I believe you’re limited to 1 instance of a role which kinda sucks. You can have threads which is fine but still puts severe caps on application scale capacity.

Tags:
Filed under .NET, Software | 2 Comments »

A warning about test driven development

Posted on June 1st, 2009

Oh wow did someone really say something bad about TDD … I mean what could be bad about this latest fad ;-)

So testing your code is of course a good thing. Anything these days to help us write better code is a good thing but definitely in moderation. I’d say with all the work going into TDD and I’ll later explain my thoughts on DDD, people are once again on the search for the holy grail of software engineering. It doesn’t exist, get over it – software engineers are artisans by definition and that is because our skill is extremely creative and you can’t wrap it up in a process to make it perfect.

What bothers me with TDD is the amount of effort being placed on “passing the test”. It is one thing to make your code easier to test but a totally different thing to engineer your entire application, just so it can be tested. Is your client paying you $$ per hour to have something that can be tested or something that works?

What about dependency injection. A hot subject for allowing the injection of mock objects or testable objects into code. My question is, if you inject a mock object into a test – is the test really real? Now inversion of control has its place, like most patterns, but I warn you against thinking you’ll now have perfect code if every class is instantiated through an IoC container.

So when it comes to application architecture I urge you to use some common sense. Pick patterns that solve problems you really have. A lot of code can be tested just fine without DI. A facade is often simpler for centralized code. Here are the general rules I would suggest to keep you on track:

  1. Build an application that meets the requirements first!
  2. Make sure it performs and scales well.
  3. Make it easier to test! but not a requirement if it means major architectural changes.
  4. If you can’t automate your test, like many user interfaces – use a person, they’re called QAEs!

You don’t have to like it but too many developers forget what the point of the code is to start with. Not to pass tests but to do something cool :)

Tags:
Filed under Software | 1 Comment »