Entries Tagged 'Web 2.0' ↓

Heroku Rails Hosting is a Joke

Heroku provide Ruby on Rails hosting. They do it their way: It’s not a server but some “dyno”s and “worker”s with mythical Japanese names. There is no MySql either: They run PostgreSql instead. Nothing so bad about this so far. There is nothing wrong with their service: It works (somewhat) and does most of the stuff you expect a RoR hosting company to do. But it’s a joke:

First of all, they have taken the concept of opinionated software to a totally new level. I mean if you’re a RoR developers you’re familiar with the concept: From naming conventions to file locations, folder structures and to the almost cult-like community lead by “DHH”. But even for RoR developers, Heroku (which I never get used to typing fast), is a new level of doing things their way: No DB other than Postgres, No source control except git, No deployment method apart from their way, and no other tool except their toolset.

Now they claim this is all to give developers a full set of tools to allow them get up to speed very quickly and have something up and running in minutes. But it is all not quite so: They claim “most” RoR apps should run just fine with Postgres as long as they don’t have any DB specific code. Well this is not quite true even for some native RoR migration scripts (and Postgres is not quite helpful in returning a decent error description, so you’d have to find your way out of the hole blindly).

On top of that, I think the whole git and heroku toolset is built for people who don’t have any other git accounts. If you do, like, let’s say an account with Github, you’d have to do a lot more to get their system to work nicely with your git setup. Look around on Stackoverflow to see people asking questions about this. This is all result of sticking to their OWN way of doing things.

Then you get to the scaling: The whole Dyno and Worker business is smoke and mirrors to hide away how much horse power you can get out of this thing. After all everyone is familiar with CPU cores, GB RAM and nowadays VPUs. Heruko’s way of describing this is based on totally new made up concepts which is again unnecessary distraction.

After that, we get to the whole DB thing: There is no way for you to access your Heroku DB if you’re using their shared DB. Granted, it is supposed to be for testing and prototyping. But isn’t that a reason for you to want to have a look into your database to see what your “prototype” or “experimental code” is doing? If you want to see what is in the database, you’d need to cough up at least $200 per month for a dedicated DB instance.

On top of that, the whole pricing thing is ridiculous: You can have 1 dyno (whatever that is), no workers (I guess background delayed job workers) and a 5MB (yes MEGA BYTES) for free. Thinking about more DB space? $15 per month gets you 20GB of PostgreSql with NO access to it from outside your app whatsoever. You actually want to look into the DB? $200 please.

Anything else is going to also cost you an arm and even more legs: You want to see AND follow the logs? Buy an “add-on”. Need an hourly CRON? $3.00 per month please… and the story goes.

So, now here I am thinking: It took me 5 minutes to get my RoR 3 app running on Dreamhost. To be fair, Dreamhost is not the most reliable hosting company. But for my $200 per year, I get to host as many apps as I want, have unlimited MySQL storage, unlimited Subversion repository and a lot more.

It took me more than half day to change my app to work on Heroku (from DB change – and yes the whole code was allegedly DB agnostic – to source control issues, git SSH RSA key issues,…). After that I have an app that is only usable for testing purposes. With these prices I’m never going to run my app on Heroku for production.

So I’m asking myself this question again: Why would I go with Heroku?

Fast 0 to 60? Nope: It is quicker to deploy a RoR app to Dreamhost than Heroku.

Unlimited (or large) Db/file storage space? Nope: 5MB Postgres + Readonly file system

No lock-in? Nope.

Scalability? Well yes – allegedly, but only if you are sitting on a pile of cash to buy a lot of Dynos (I guess they make your app scalable, right?)

So why? If you are competent enough to run your own web server and have some money (not too much), then why don’t you run it on EC2 yourself?

If you don’t want to deal with web servers and load balancers (although EC2 makes it super easy), then why not go with something like EngineYard?

If you want something you can just try an idea then why don’t you do it on Dreamhost or another bog-standard apache shop.

If you want control, but don’t have the money (well in that case you should go near Heroku), why not a VPS like Linode?

However I look at it, I can’t find a good reason to go with Heroku. That’s why I think it is a joke. And not a funny one.

Amazon CloudFront CDN and ASP MVC

I needed to use a CDN in my ASP MVC app and needed it to be easy to develop against. I chose Amazon CloudFront since our servers are running on Amazon EC2 and we are also using Amazon S3 during our deployment. You can get a good introduction and step-by-step on CloudFront here.

As for the ASP MVC side, I wanted to have something like Url.Content where it converts my URL to my CDN URL while allowing for multiple development environments.

Here is how I did it:

A helper extension class on System.Web.Mvc.UrlHelper to add a new method to Url: This one is CdnContent

Here is an implementation

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Web.Mvc;
using System.Configuration;

namespace CdnHelpers
{
public static class CdnHelpers
{
private static AppEnvironment _appEnvironment = AppEnvironment.Unknown;
private static string _cdnBase = string.Empty;

private static AppEnvironment AppEnvironment
{
get
{
if (_appEnvironment == AppEnvironment.Unknown)
{
_appEnvironment =
(AppEnvironment)
Enum.Parse(typeof (AppEnvironment), ConfigurationManager.AppSettings["App.Environment"], true);
}

return _appEnvironment;
}
}

private static string CdnBase
{
get
{
if (string.IsNullOrEmpty(_cdnBase))
{
_cdnBase = ConfigurationManager.AppSettings["Cdn.Base"];
}

return _cdnBase;
}
}

public static string CdsContent(this System.Web.Mvc.UrlHelper url, string contentPath)
{
if (AppEnvironment == AppEnvironment.Local)
{
return url.Content(contentPath);
}
else
{
contentPath = contentPath.TrimStart('~');

return string.Concat(CdnBase, "/", AppEnvironment.ToString().ToLower(), contentPath);
}
}
}
}

AppEnvironment is an Enum:

    public enum AppEnvironment
    {
        Unknown,

        Local,

        Test,

        Dev,

        Staging,

        Production
    }

You need to add two keys to AppSettings of the Web.config:
App.Environment to determine which environment the code is running as and
Cdn.Base which would be something like http://cache.mydomain.com (no trailing slash)

Also add the namespace of the helper class to System.Web/Pages/Namespaces under Web.config

This should be it. Now you can replace a Url.Content with Url.CdnContent in the code.

I didn’t want to redirect all files by their extension to CDN but that’s not difficult to implement.

On deployment to Amazon:

  • Amazon CDN files and folders are case sensitive.
  • Create folders with the name of your environments under the root of the S3 bucket and deploy the files and folders there.

Meritocracy in Silicon Valley

Evan Williams , the founder of Twitter has made his millions in Blogger. He is very well connected in Silicon Valley and Web 2.0 ecosystem. I also admit that Twitter can be a useful tool: Integrating it with other social networking websites like Facebook or even personal blogs can have good uses.

Everyday there are tens of new websites popping up on the internet providing different services: From URL shrinkers to Corporate collaboration tools. Now if each one of them had the problems Twitter has had for the past couple of months, it would have been dean in the water. Very dead indeed.

It was revealed recently that Twitter has only 1.5 million users. It might sound a lot but compared to many other websites, it is not a lot at all.

I guess Mr. Williams should be very lucky to have such good friends in the media to fan his hype so feverishly so he can manage to increase the number of the users of his service like that.