New BBC Comments Module: Technical Overview
I'm a developer of the Audience Publishing Services team in Programmes and On Demand in BBC Future Media. As Jessica has explained last week we rolled out a new comments product to all BBC blogs.
As a recent addition to the APS team I was tasked with revamping the commenting system and bringing it onto the BBC's Dynamic Web Application Platform (the Platform - PHP with BBC flavoured Zend framework).
The old system comprised of a set of API's which would allow developers to interact with the APS backend system. This would allow them to retrieve a list of comments (we call it a comment forum), and post comments back to it.
For ease of use, with products such as blogs, there was a set of SSI includes which would be embedded within a page which would pull in the necessary assets, forms etc and do all the API calls necessary to make it all work.
So why change?
The old architecture was basically a set of API's to the APS backend (which is tried & trusted), but the frontend implementation was difficult to implement and was totally geared towards working on the older SSI based servers, not the Platform.
We needed an easy way of adding comments to pages on BBC Online which would work on the Platform, would be backwards compatible with the older servers, and one that would stand up to the high traffic demands of clients such as BBC News and BBC Sport.
So what did we do?
Firstly, whatever system we built, it had to interface with the APS API (our source of comments and comment forums). We needed something on the Platform which would act as a wrapper for these API calls, so we build the Comments Service. The Comments Service is the bridge between the Platform and APS. Functions are called on the Platform using the Comments Service, which in turn calls the relevant APS API calls, which then returns JSON back to the Comments Service, to return it back to the application which called it initially.
It's not unusual for us to see peak levels of traffic of up to 500 transactions a second for News pages using Comments, so the Comments Service makes use of Memcached, this enables us to cache the response from APS for a short while, to relieve pressure on the APS Service at times of heavy load.
An important thing to note in the diagram above (taken from our trial of Comments on BBC News Stories), is the scale of the y-axis for each of the graphs. Even though the requests per second from the Comments Module to the Comments Service peaks at nearly 120 requests/second (requests for a list of comments), the requests to the Comments Service to the APS Service never goes above 10 requests a second. This enables us to cope with the large spikes in traffic and scale the module to meet the demanding needs of the bbc.co.uk domain.
The Comments Module uses the Comments Service to retrieve the comment forums from APS, and then renders them using the BBCs templating system - Spectrum. This takes care of rending the correct HTML, script, CSS tags etc.
So whats new in the new BBC Comments Module?
When this is enabled on a site, or comment forum, it enforces a minimum time interval between posts to the same comment forum by the same user. This is like a cooling off period between posts.
Ajax Comment Posting
We found the old way of linking to a comment could be confusing, as in a long list of comments, it wasn't always obvious which one had been linked to, so we've introduced highlighting for linked comments. See here and here.
Comments Per Page
We've reduced the number of comments per page to 100 for all blogs (from 500). This reduces page size, which is better for bandwidth and page delivery times.
HTML in Comments
We allow a small set of tags to be used to style your comments on BBC Blogs. These are: <blockquote>, <em>, <li>, <p>, <pre>, <q>, <strong>, <ul>, <ol> and <b> These are not currently available for use on BBC News comments.
We've got a full roadmap for new features to be introduced in the coming months, i'm looking forward to telling you all about them, as we introduce them.
We're always interested to hear your thoughts, please use the comment box below!
Richard Summers is lead developer, User Publishing Services, Programmes and On Demand, BBC Future Media.