Linode vs Digital Ocean

Digital Ocean* is relatively new in the cloud hosting industry but is getting a lot of serious attention as of late mainly because of its price and SSD hard drives. There are also a lot of stuff going on at Linode* lately where they are upgrading their hardware, double the RAM and faster network. Let’s take a closer look between them in terms of resources/price.

For comparison, we will use Linode 1GB plan and Digital Ocean 1GB Droplet.

Pricing (Updated)

Linode:

  • CPU: 1 Core
  • RAM: 1GB
  • Storage: 24GB SSD
  • Bandwidth: 2TB
  • Pricing: $10.00

Digital Ocean:

  • CPU: 1 Core
  • RAM: 1GB
  • Storage: 30GB SSD
  • Bandwidth: 2TB
  • Pricing: $10.00

Pricing/specs wise, both of them are identical, except Do offers 6GB more storage.

Performance

There is a detailed performance benchmarking between Linode and Digital Ocean by Jason Ormand and also bits and pieces can be found on Hacker News.

  • Network: Linode has better network connectivity compared to DO as mentioned here on Hacker News. Currently, there is no internal network for DO droplets but is coming soon.
  • CPU: All Linode’s plans come with 8 cores so Linode clearly has an upper hand in terms of CPU performance.
  • I/O: All DO’s plans come with SSD storage so it’s blazing fast. DO wins hands down.
  • RAM: DO is slightly better in RAM speed compared to Linode.

If CPU performance is important for your app or if your servers need to communicate internally (e.g. separate app and db server), you should go with Linode. Otherwise, DO gets my vote.

Others

  • Data center: Linode has more options compared to DO. Linode: Newark, Atlanta, Fremont, Dallas, London and Tokyo. DO: New York, San Francisco, Amsterdam and Singapore.
  • iPhone app: Linode has one and it’s really convenient to manage your servers on the go.

Support

I can’t speak on behalf of DO as I’m not one of their customers yet but I can speak highly for Linode. I’ve been with Linode for more than 4 years and their support is second to none. Their response time is usually less than 3 minutes and their support staff know what they are doing.

Benchmark

Here is a nice post written by Remco Bron comparing EC2 vs Linode vs Digital Ocean. For $20/month, Linode clearly gives you a better performance thanks to their 8 cores CPU but I expect Digital Ocean to catch up very soon.

Conclusion

I still think (as of writing) Linode is more suited for production while Digital Ocean is great for development. Feel free to chip in in the comments below, especially you have experienced both Linode and Digital Ocean.

Update: DO has grown a lot over the past years and being used by many for production. I think both are great, but my inexperience with DO and as a Linode customer for many years, I would still go with Linode… but DO’s $5 plan is a killer. Super handy for development or some light hosting that doesn’t require lots of RAM and CPU.

*Note: My referral link. Sign-up using my link if you think this post is useful, I would appreciate the referral.

Sublime CodeIntel Configuration for virtualenv

If you are using Sublime Text 2, Sublime CodeIntel is a must have plugin. It provides code intelligence for languages ranging from Python to Javascript with features like code autocomplete and jump to symbol definition.

Working with virtualenv

It supports Python default installation out of the box but if you are working with virtualenv, then you will need to manually configure CodeIntel to pick up your virtual environment.

Configuration files are located at ~/.codeintel/config or project_root/.codeintel/config (you might need to create this yourself). Change the config file like so:

The example above is based on my virtualenv setup, yours might be different. So, please change accordingly.

Managing Django Static Files on Heroku

Deploying and running Django apps on Heroku is really a no-brainer, except for one thing — serving static files via collectstatic.

I run collectstatic as usual, using heroku run command just like how I did it for syncdb. It worked but I’m getting 404 error when serving static files.

It turns out that running collectstatic via heroku run spins up a new dyno and collectstatic is running in an isolated environment. So, all the collected static files are deployed to that location and only for this new dyno and the dyno attached to our Django app can’t access that. — Heroku support staff

Solution

The dead simple solution would be to run collectstatic as part of the Procfile before starting the app. We need to “chain” together our Procfile commands for the web process, like so:

OK there you go, no more 404 error when serving static files from your Django app on Heroku. Plus, every time you deploy your app, newly added static files will be collected automatically.

Update

There are a lot of questions about the configurations. Cross check with my settings.py here http://pastebin.com/H43gRKsJ

Important thing here is your STATICFILES_DIRS. Make sure to include your project_name/app_name/static here. In my case, I have project_name/staticfiles for the STATIC_ROOT. Change STATIC_URL = ‘/static/’ if you want to serve from Heroku, same goes to ADMIN_MEDIA_PREFIX = ‘/static/admin/’

Finally add this to your urls.py in order to serve from Heroku.

urlpatterns += patterns('',
 (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
 )

Files could be access as such:

/app/project_name/staticfiles/style.css > http://flaming-fire-999.herokuapp.com/static/style.css
/app/lib/python2.7/site-packages/django/contrib/admin/media/css/login.css > http://flaming-fire-999.herokuapp.com/static/admin/css/login.css

Please note that this is not the best way to serve static files but it works. One last thing, you still need to go through all these things if you are using django storages and django compressor to serve static files via Amazon S3 because django compressor needs a temp file system cache on Heroku.

Start-Up Chile: Want to Make The Cut? Here Are Some Advice

The 3rd and final round of Start-Up Chile 2011 application is now open. If your startup is still in “alpha/beta” mode, you are highly encouraged to apply (even your startup is not, do apply). My startup, Flvrd (still in beta mode) was one of 154 startups around that get selected in the previous round.

If you are applying or think to apply, one of the questions that usually goes through your mind is: “Is it hard to get into Start-Up Chile?

Well, honestly I don’t think it is hard based on Flvrd’s application but it is getting tougher from round to round because more and more startups are applying. FYI, Round 1 (329 applications, 110 startups selected) and Round 2 (650+ applications, 154 startups selected).

But there are a few important areas that I think you need to really focus on. So lets go through those (together with my personal advice) by looking into the judging criteria.

  1. Human Capital (weight: 33%): quality of the talent and commitment of the founding team members.
  2. Project (weight: 34% – composite): Strategy, differentiation, and innovation factors of the product/service purported:
    • Product/Service (weight: 17%)
    • Market (weight: 17%)
  3. Environment (weight: 33%): Value of the founding team’s networks for the Chilean entrepreneurship ecosystem.

Human Capital

They are looking for an awesome team. All startup incubators are looking for the best team and not the best idea. So make sure you have an awesome team — good chemistry, work well together, complementary skill sets and some impressive stats about the team members.

In brief, the Flvrd Team: Flvrd has two co-founders (Koekoe and I) with complementary skill sets. We have known each other for more than 3 years and we work together on projects and group assignments during our time in university. We have also participated and won in a number of international tech and entrepreneurship competitions while in university. Bonus: we are a couple.

How about a single founder? Well, to my knowledge there are a number of single founder startups that got accepted. So if you are alone, your Start-Up Chile dream is not dead, never. There are other factors which are more important than this. So don’t worry.

Project

This is all about your idea/product and they are looking for globally scalable ideas/products. If your idea is super local and could not be replicated in other countries, you might want to rethink your idea.

I don’t know how well Flvrd scores under this section but if you don’t have a world changing idea/product — I don’t think this will put you in a disadvantaged position. FYI, Flvrd is neither a world changing idea nor follows the blue ocean strategy. We just do things differently.

But It is important to have a working prototype. It shows your commitment and also your execution. Remember the popular saying? “An idea is nothing without execution”. So having a real product where you and your team have been working on for some time is a huge plus.

A pitch video is also important in the case where the judges didn’t get the picture of what you are doing, a KISS video will help you explain your idea/product. FYI, we spent more than a week working on the pitch video but well worth it.

You are also required to answer questions related to your startup’s execution and business plan. So, make sure you know what you are doing, what is your plan, the market, competitors, etc. You have to do some basic research to answer these questions well — don’t assume!

Side note: The best way to keep up with your market and competitors is to follow tech and startup blogs like TechCrunch, Mashable, ReadWriteWeb, The Next Web, VentureBeat, etc.

Environment

This is where they want to know how you can contribute to the Chilean entrepreneurship ecosystem by leveraging on your skills, experiences and your networks. So, it is good to have an established network back home so that you can link them to Start-Up Chile and Chilean entrepreneurship culture/ecosystem as a whole.

Bonus: Make your application stands out and the best way to do it is through video.

So, there you go some tips and advice for startups applying for Start-Up Chile. Feel free to ping me if you have any questions.

Reminder: You have until October 27th 2011 to make the cut. Act now!

Hello WordPress, Bye Posterous

I’ve been switching back and forth between various blogging platforms  — WordPress, Tumblr and Posterous. If my memory serves me right, I started off with WordPress, then Tumblr, and back to WordPress before ended up with Posterous. Now, I’m back on WordPress.

Past few months, I’m contemplating a move from Posterous for two reasons — speed and flexibility.

  • Speed — Posterous is slow, and getting slower after they roll out Posterous Spaces. Back in the early days when I started using Posterous, loading my blog and the blog management pages is pretty fast but now, speed bump everywhere. Try search for posterous is slow on Google.
  • Flexibility — Posterous’ simplicity is great, but because of that it’s not very flexible. You can’t embed Javascript snippets and do much modification besides the look and feel. Those like me who want more control, a self-hosted WordPress is a better choice.

So, it’s time to switch back to a self-hosted WordPress blog and here I am. Now I’ve total control over every aspect of my blog from the speed to the look and feel. If you are wondering how I migrate from Posterous to a self-hosted WordPress, check out this post by Antonio Cangiano.

Django “Global” Template Variable

Depending on the project you are working on, you might want to access one or more template variables across all your templates like the User object. If you are making news or blog project, one example would be navigation bar item, say a category list.

You might be tempted to pass the category list from your views or create a template tag for that; but that just violate the Django’s DRY principle. So the best way would be through custom context processor. Writing your own is actually very easy.

1. Writing the context processor function.

You can put this function anywhere in your project. My preference is to place this code inside a context_processors.py file under the related app.

# The context processor function
def categories(request):
    all_categories = Category.objects.all()

    return {
        'categories': all_categories,
    }

Note: Each context processor must return a dictionary and takes only one arguement, HttpRequest object.

2. Point it to your TEMPLATE_CONTEXT_PROCESSORS in your settings.py file.

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request",
    # ...
    "yourapp.context_processors.categories"
)

Now categories is available for use in all your templates.

Done!

Announcing: Fryday App

Today, I’m happy and proud to announce the launch of Fryday an experimental project by @koekoecrunch and me, @matthewphiong.

Fryday What?

Fryday Logo

Fryday is a web app that let you express your anger, frustration, hatred, outrage or whatever negative on Friday. Yes, just on Friday. It allows you to post your messages, pictures, videos or voice screams securely (secured with bank-level data encryption). You’ll be able to share with your friends, your selected friends and have a good laugh about it.

One common use of Fryday is to take a picture of your boss, doodle on it (uhmm… like “Stop throwing me work you bitch! It’s Friday, Friday, gotta get lost on Friday”) to release your anger and then upload it to Fryday. You can select which friends to share with and have a LMFAO!

Why Fryday?

As we all know, Friday is the most tense and frustrating day of the week. This very day that is all about work, work and work and deadline, deadline and deadline. When we are all excited and planning our weekend, Friday will come and spoil it. So, we really can’t stand Friday and because of that we really want to FRY it! Hence Fryday was born.

Oh BTW, Fryday (the name) is highly inspired by Rebecca Black’s Friday. Thanks Rebecca! We ♥ your Friday.

Fryday FYI

We have been working on this on and off for more than 6 months now. Here are some unbelievable and shocking stats (even we are shocked!)

  • 1000 litres of sweat drained.
  • 100 kilograms of caffeine consumed.
  • 500 SMS sent.
  • 250 papers wasted.
  • 25 Fridays wasted.
  • 500 kilograms of chocolate strawberry cakes consumed.
  • And most recently… 100 hours of Rebecca Black’s Friday!

Excuse us if Fryday is not as good as it sounds or hyped. FYI I’m learning Django and Koekoe is learning Illustrator while building this app, we are still very noob. We hope this app will make you feel as good as having a delicious chocolate strawberry cake on Friday. Anyway, we hope you don’t hate it :)

P.S. Happy 1st of April :)

KTHXBAI,
matt & koekoe

Price War: Linode vs Amazon EC2 vs Rackspace Cloud Servers vs Windows Azure Virtual Machines

Updated: 

  • 18 September 2012. Slicehost is now Rackspace Cloud Servers and added Windows Azure.
  • 31 October 2012. New EC2 price.
  • 10 April 2013. Linode NextGen specs.

It’s time for a “cloud” war but on the pricing side. So what is the real price per month between the four most popular cloud/VPS hosting providers? Which one has the best value for money? Let’s find out with a simple resource/price comparison below.

Again, the contenders are:

I’m currently hosting a few blogs and websites on a Linode 1024 plan (1024MB RAM). The incoming and outgoing bandwidth are approx. 70GB and 140GB respectively/month. So I’ll use these data in the calculation for EC2, Cloud Servers and Azure Virtual Machines and assumes 730 hours of service/month.

The Numbers

For Linode, the price is fixed with preallocated storage and transfer with free incoming traffic.

Linode 1024 Plan

  • CPU: 8 Cores
  • RAM: 1024MB
  • Storage: 24GB
  • Transfer: In (Free), Out (2048GB/2TB)

Price/month: $20.00

Note: Linode has upgraded all of their plans with better hardware, network and double the RAM for the same price (actually it is $0.05 more for all plans). You can read more about their NextGen of Linode on their blog: NetworkHardwareRAM.

Amazon EC2 Micro Instance

Price varies between regions, we’ll use the cheapest one.

  • Instance/hour: $0.02
  • CPU: 1 Core
  • RAM: 613MB**
  • Storage: EBS storage only ($0.10/GB), say we use 20GB
  • Transfer: In (Free), Out (First 1GB is free, subsequent GB up to 10TB is $0.12/GB)

Note: EC2 Micro instance doesn’t come with instance storage, that is why we need to use Amazon EBS.

Instance/month: $14.60
Storage/month: $2.00
Transfer (In)/month: $0
Transfer (Out)/month: $16.68

Price/month: $33.28

Rackspace Cloud Servers

  • Instance/hour: $0.06
  • CPU: 1 Core
  • RAM: 1024MB
  • Storage: 40GB allocated
  • Transfer: In (Free), Out ($0.12/GB)

Instance/month: $43.80
Storage/month: $0
Transfer (In)/month: $0
Transfer (Out)/month: $16.80

Price/month: $60.60

Windows Azure Virtual Machine XS

  • Instance/hour: $0.013
  • CPU: Shared
  • RAM: 768MB**
  • Storage: Locally redundant storage ($0.095/GB), say we use 20GB
  • Transfer: In (Free), Out (First 5GB is free, subsequent GB up to 10TB is $0.12/GB)

Note: The free first 5GB outgoing transfer only valid until 30 June 2013. More here.

Instance/month: $9.49
Storage/month: $1.90
Transfer (In)/month: $0
Transfer (Out)/month: $12

Price/month: $23.39

So we have it: Linode ($20.00), EC2 ($33.28), Cloud Servers ($60.60) and Azure VMs ($23.39)

Here, the clear “winner” is Linode*. But again, this is not really an apple-to-apple comparison because the VM’s performance is not taken into consideration. But in terms of specs and resources, Linode came out top. Linode is more superior in terms of hardware with 8 cores of CPU and very generous with their outgoing bandwidth, 2TB. But please take not that having more cores doesn’t mean more processing power.

Conclusion

As noted here, go for cloud if you want to run your stuff for a short period of time (few hours or days. You can still use Linode and get credited for the unused time for the rest of the month), CPU intensive stuff or web apps that have unpredictable load and need to scale up and down easily and quickly. If you want to host a blog or website (long-term) go for VPS. I would recommend Linode* over the rest. It’s really hard to argue when comes to hardware and price/resources. It’s simply the best bang for the buck. I’ve been with them for many years now, great support (usually less than 3 mins response) and great performance.

*Note: My referral link. Sign-up using my link if you think this post is useful, I would appreciate the referral. Otherwise, just hit linode.com in your address bar.

**Closest available RAM option to 1GB.

Facebook OAuth 2.0 for Canvas App Explained

Facebook is getting better in providing OAuth 2.0 support for its canvas app, that is apps on facebook.com. But one thing that drives people nuts is the documentation. A lot of people getting stuck while trying to adopt the new OAuth authentication method and the Graph API because lack of proper documentation for developers.

This post will explain how simple actually getting OAuth to work with canvas app (both FBML and iFrame). There are two references you need:

  1. http://developers.facebook.com/docs/authentication/
  2. http://developers.facebook.com/docs/authentication/canvas

Authenticating User

The docs on authentication explains that you need to perform two steps to obtain the access_token that is:

  1. Redirect the user to https://graph.facebook.com/oauth/authorize  with your client_id and the URL the user should be redirected back to after the authorization process (redirect_uri)
  2. Exchange it for an access token by fetching https://graph.facebook.com/oauth/access_token. Pass the exact same redirect_uri as in the previous step (1).

For canvas app, it is much more simpler. You do not need to perform step 2. What you need is just step 1, the authorization process. See code below:

After this process, you can parse the signed_request (see below) to get the access_token.

The signed_request

All canvas apps will have this signed_request parameter attached to the callback URL that contains the user_id, oauth_token, expires and profile_id. You need to parse the signed_request to get these info. Example codes can be found here: PHP, .NET (C#), Python, Java.

So, now you are able to parse and get those info, and yes you will get the oauth_token directly. If you get nothing returned (no user_id, oauth_token, etc), don’t freak out. This means the user has not authorize your app yet. So, just perform the authorization process above and you are good to go!

The Good and Bad

The good thing is, it much more simpler — you no longer need to request for a new access_code/access_token when it expires, back and forth. Just parse the signed_request to get the access_token (oauth_token).

The bad thing is, the authorization process doesn’t work well with iFrame-based canvas app. You will get a Facebook inside Facebook effect, that is a Facebook page loaded inside the Facebook frame.

The Workaround for iFrame

The current workaround is using Javascript to load the authorization URL on top:

This will solve part of the problem. After the user authorized your app, Facebook will redirect back to your site specified by the redirect_uri. You will get the problem again (you will see a Facebook logo with a ‘Go to Facebook.com’ link). After much hack-around, I found out that by adding type=’user_agent’ and display=’page’ to the authorization URL, the problem is fixed. See the modified URL below:

There you go.