Social Contest: Getting Our Azure On
As those of you at ZendCon may already know, Microsoft’s Windows Azure division is running a contest via social media. They even have a spiffy app showing entries and winners. (Sadly, you have to be present to win.) What you may not know is that the back end for that app is a PHP application hosted on Windows Azure, using many of its services to create a scalable social contest app. The contest app is now open-sourced on GitHub: Social Contest, and musketeers.me, php[architect]’s parent company, developed it at the behest and sponsorship of the Azure team.
One of the goals was to develop an application on Azure in PHP and give feedback on the process. From the beginning, we had the task of integrating with Social Cloud, a node.js application which sampled various social media fire hoses for a particular word or words. It is designed to scale for incredibly popular words across the sampled services. To integrate with separate applications, it puts its output into an Azure Service Bus, the more feature-packed of the two queuing services in Azure. So we knew we had to integrate with it as well as provide administrative tools for approving entries and options for selecting winners.
Never having used Azure before, we initially developed for the narrow use case of this particular conference. Being familiar with other cloud-based services, we went with the familiar: we fired up a Linux instance from a predefined image. Being unconstrained by legacy code, we chose an Ubuntu 13.04 instance with PHP 5.5. Social Cloud also runs on Linux. That’s right: our first services on Windows Azure were Linux VMs.
Being ZendCon, we were tempted to use Zend Framework 2, but it seemed like overkill. Fortunately, Matthew Weier O’Phinney has developed Phlyty, a micro-framework built atop Zend Framework 2 components. This fit the bill nicely. Since we had a free instance to play with, we wanted to try SQL Server for our persistence layer. It still requires more work to connect to than a MySQL instance (which Azure also has), but we were able to get it running and quickly prototyped our application’s functional requirements.
However, Cory Fowler of the Azure team challenged us to make the app scalable for a global online conference (which might have extremely high rates of entries) and to reduce its dependence on third-party services. We accepted his challenge and quickly refactored the application – it literally took two days, total. We added more Service Bus queues to change entries from one state (such as Incoming) to another (such as Approved or Denied). We moved the persistence layer from MSSQL to use Azure Tables, the NoSQL service available. By using Tables, we were able to have very quick retrieval and querying of entries in each state. Finally, to reduce dependence on TwitPic or other third-party services, we cached the images in Azure Blob storage – which as it turns out, has a CDN in front of it, making it a scalable choice. The Azure PHP SDK proved to be very helpful with lots of example code and, to my mind, better explanations of Azure features than on the main Windows Azure website.
We’ll cover the architecture in more detail in a separate post, but bottom line: Azure makes it easier for someone coming from a LAMP background to develop scalable, decoupled web apps using its cloud services. In fact, it turned out as fast or faster to build using the cloud services than it was to integrate PHP with a different relational database. Which way you choose to develop now can be based more on cost and level of service considerations rather than complexity of development. That’s no mean feat.
Leave a comment
Use the form below to leave a comment:
Responses and Pingbacks
September 22nd, 2014 at 9:24 am
[…] used the SPL for a common interface to queries returned from either a queue or a database in the Social Contest app we […]