Archive for August, 2007

Using EC2 and Amazon Webservices for Hosting Facebook Applications

Bookmark and Share

Most webdevelopers are used to steady long term growth with occassional spikes, the kind of stuff you can just about get away with on shared hosting or a basic dedicated server. Facebook development can be a completely different kettle of fish, even relatively small apps can expect thousands of regular users hitting their app every day, and often growing very fast. You can see inexperienced facebook developers being caught with their pants down, how many apps out there are throwing up ‘not responding’ errors within a matter of days of being accepted into the application directory?

So you need to think ahead, particularly about your hosting requirements, you should plan an infrastucture where you can quickly plug in a few extra load balanced servers, and keep plugging more in as your app grows. This involves a set of skills beyond the scope of basic php/mysql app development and with a standard dedicated server setup, a significant increase in cost.

Amazons Webservices is one possible solution, in particular their “Elastic Compute Cloud” - EC2 service. EC2 essentially provides unlimited computing power through virtual servers - nodes, you can clone nodes and start up a new instance of a node within a couple of minutes and the beauty is you are billed by the hour not the month with no start up fees. Additionally you can easily update and save an image of your node so you can continue to tweak your virtual server, save it as an image and then use that image to create more nodes.

How To Set Up A Facebook Application On EC2

So I’ll give a rough outline to how you could host your application on EC2.

  1. Create An AWS account
  2. Go through the get started tutorial to get the idea of how it works.
    This basically gets you familliar with the command line tools for setting up a node. Once a node is started you get an IP address and just log into it like you would any other unix server.
  3. Plan your infrastructure.
    • A typical set up would be Webservers serving the application, Database Master Server, Database Slave Servers.
      To get you started, amazon has some good starting points, there is a nice apache webserver image and a separate mysql server image.
    • Additionally you’ll need to partition your application
    • At the very least separate database reads and writes, so all reads are sent to the slaves and all writes to the master
    • Consider how multiple webservers can distribute the load, they could all be clones or you could farm of different tasks to different servers
    • Think about backup. Again the good thing about amazon EC2 is the fact you can save an snapshot of your node, this is especially nice if all your data is in a database as all you need to do is keep an up to date image of your webserver and do regular database backups, then you could in theory recover from anything in a few minutes (depending on database size). For live database backups you will need to be using replication and you can then safely perform backups of a slave. And you should back up the data to S3 (the snapshot images of nodes are pushed onto s3 automatically).
  4. Think about DNS, you’ll need a way of farming the requests to different servers and facebook (at time of writing) only gives one callback url. Fortunately this is fairly easy to get round with round robin DNS which is easy for transparently spreading requests accross your webservers. You will probably prefer to have your DNS separate from EC2 as IP addresses change if a node is shut down.
  5. Once you have thought through these points, you can now bear them in mind for planning/modifying your app, so next you should start up an EC2 instance (review the getting started tutorial) and start coding

Caveats

  • This biggest caveat is ‘no persistant storage’ - if you terminate an instance all data is lost forever. However in the context of such a specific environment as a facebook app, this should not be a big problem, you just need to make sure you have planned a regular offsite data backup and take regular snapshots of your nodes.
  • IP Address change, you IP address will change if you terminate an instance so you’ll need to have a low TTL on your DNS servers so IP addresses will never be cached for too long

Attention Developers: Facebook Delete Applications Without Warning

Bookmark and Share

UPDATE Mr Kirkland interivew by IDG

So after an exciting start with our tracker application reaching 8000 users within 3 days after launch facebook have deleted it without warning.

Admittedly we recieved a number of ‘Facebook TOS reports’, but they were all from users that had misunderstood what the application did and were essentially false alarms. Moreover our application had been reviewed and accepted into the facebook directoty and we even had recieved direct confirmation that our idea was okay:

Hi Chris,

Thanks for your cooperation with our policies. To answer your question,
yes, anonymously tracking ‘hits’ would be fine (as long as the user cannot
tell who specifically has been visiting their profile).

Please let me know if you have any further questions.

So you can imagine just how pleased we were with the reply after I had questioned the reason for the disappearance of Tracker:

Hi Chris,

Upon further review of your application we found that it violates our Terms
of Service. You asked me if tracking the number of hits anonymously would
be within our Terms of Service. This would be, but it should only be
possible if the other user visiting the site has also installed the
application. I apologize if my answer to your initial inquiry was unclear.
Thank you for letting us know about this other application. We’ll be
reviewing its functionality as well.

Thanks for contacting Facebook,

So we were given no opportunity to alter the application, no warnings that they would do this, and my attempts at discussing the erronous User TOS reports with facebook merely recieved generic replies.

Conclusion

If you are developing a facebook app, watch out it might suddenly dissappear!
Tracker

Ooyala - Contextual video advertising has arrived

Bookmark and Share

Some ex Google bods have taken contextual video to the next level. A number of companies are wrestling with how to “monetise” video content. Google video are inserting supposedly unobtrusive ads within youtube content for instance. Nothing has of yet been truly pull adevrtising as well as contextual until now.

Calif.-based company Ooyala has developed a new interface whereby viewers can click on various images — a car, a necklace, a wristwatch, an actor — within a video to get more information about the specific product or person.

If there is a technology behind this that understands what an object is and then contextually relates it to ads then it is very advanced. Some people have speculated that it utilises RFID technology, other than that it would be a really laborious task studying each frame.


Viral Facebook Applications Part 2

Bookmark and Share

Okay so the first facebook application realeased by MrKirkland hasn’t quite hit the popularity of Pirates or Zombies, but 10,000 users and almost a million page views in 3 weeks is still not bad in our books.

For our second application we thought we’d try something more practical, a “who’s been on my profile” application. We have dubbed this application “tracker“. However this app had a slightly controversial birth, namely we had to axe the ‘who’ part of the tracking. Despite a careful review of the Terms and Privacy we couldn’t find unambiguous langauge indicating whether an application recording who has visited your profile would contravene these terms.

So we decided to release the application and wait and see what happened - we’d found the developer help email responses a little slow, so we figured facebook would come to us faster this way! Well sure enough within a few hours of submitting the app to the application directory we received a refusal. However the refusal was rather vague:

Thanks for your submission of “Tracker” to the Facebook Platform’s Product Directory. We have reviewed your application, and unfortunately cannot yet add it to the directory because it violates the Facebook developer terms of service (stores user data beyond the context user session or specified timeout). Please fix this problem and resubmit the application.

So after reviewing the terms, we concluded we were violating the condition relating storing non-permantently storable data for more than 24hours, so our solution was to make only the last 24 hours of ‘who’ available.

We submitted the app a second time and were again refused. Thankfully though we recieved an email specifically indicating our goof:

Thanks for your application submission. Unfortunately we cannot approve
your application “Tracker” at this time because it is in violation of our
Terms of Service. Your application is tracking users who have visited
another user’s profile, even if the users have not opted into the
application. This is a serious violation of our users’ privacy. Please
correct this as soon as possible.

A pity perhaps as without even being in the directory the app had attracted almost 1000 users - seems that this is a popular feature! Anyway, we still felt a profile ‘hit counter’ would be worth having, especially as it seems no one had offered this application yet.

So now the tracker application has just been accepted into the directory, and has made a good start - close to 1000 new users within 12 hours of being listed, that’s about 5 times better than the sentence game!


About MrKirkland

more...

Tweets

Posting tweet...

Timezone

  • JST: 2010-03-11 08:56
  • GMT: 2010-03-10 23:56
  • PST: 2010-03-10 15:56
  • EDT: 2010-03-10 19:56

About

You are currently browsing the Mr Kirkland weblog archives for the month August, 2007.

Longer entries are truncated. Click the headline of an entry to read it in its entirety.