Document directory
- Online Systems
- Messaging and events
- Batch and asynchronous systems
- Data stores
- Operating System and Configuration
WrittenDave Beckett• Filed under Technology
At Digg we have substantially rebuilt our infrastructure over the last year in what we call "Digg V4 ". this blog post gives a high-level view of the systems and technologies involved and how we use them. read on to find out the secrets of the Digg engineers!
Let us start by reviewing the public products that Digg provides to users:
- A social news site for all users,
- A personalized social news site for an individual,
- An ADS platform,
- An API service and
- Blog and documentation sites.
These sites are primarily accessed by people visiting in browsers or applications. Some people have Digg user accounts and are logged in; they get the personalized siteMy news. Everyone gets the all user site which we callTop News. These products are all seen on'digg.com
And the mobile site'm.digg.com
'. The API service is'services.digg.com
'. Finally, there are'about.digg.com
'(This one) and'developers.digg.com
'Sites which together provide the company blog and documentation for users, publishers, advertisers and developers.
This post will mainly cover the High-level technology of the social news products.
What we are trying to do
We are trying to build social news sites based on user-submitted stories and advertiser-submitted ad content.
Story submission: the stories are submitted by logged-in users with some descriptive fields: a title, a paragraph, a media type, a topic and a possible thumbnail. these fields are extracted from the source document by a variety of metadata standards (such as the Facebook open graph protocol, oembed plus some filtering) but the submitter has the final edit on all of these. ads are submitted by publishers to a separate system but if dugg enough, may become stories.
Story lists: All stories are shown in multiple "story lists" such as most recent (by date, newest first), by topic of the story, by media type and if you follow the submitted user, in the personalized social news product, mynews.
Story actions: users can do actions on the stories and story lists such as read them, click on them, Digg them, bury them, make comments, vote on the comments and more. A non-logged in user can only read or click stories.
Story promotion: several times per hour we determine stories to move from recent story lists to the top news story list. The algorithm (our secret sauce !) Picks the stories by looking at both user actions and content classification features.
How do we do it?
Let us take a look at a high level view of how somebody visiting one of the Digg sites gets served with content and can do actions. the following picture shows the public view and the boundary to the internal services that Digg uses to provide the pages, images or API requests.
The edge of our internal systems is simplified here but does show that the API servers proxy requests to our internal back end services servers. the front end servers are always Ally stateless (apart from some caching) and rely on the same service layer. the CMS and ads systems will not be described further in this post.
Taking a look at the internal high level services in an abstract fashion, these can be generally divided into two system parts:
-
Online or interactive or synchronous
-
Serve user requests for a page or API directly or indirectly. these have to return the response in some number of milliseconds (for services) which in aggregate to the user cannot be more than 1 or 2 seconds to give a good page response. this includes des Ajax requests which are asynchronous for the user in the browser but are request/response from the serving system point of view.
-
Offline or batch or asynchronous
-
Serve requests that are not in the interactive request-response loop and are typically only indirectly initiated by a user. The work here can take from seconds, minutes or hours (rarely ).
The two parts above are used in Digg as shown in this digoal:
Looking deeper into the components.
Online Systems
The applications serving pages or API requests are mainly written in PHP (front end, Drupal CMS) and Python (API server) using tornado. they call the back end services via the thrift protocol to a set of services written in Python. descrithings are cached in the online applications (Fe and be) using memcached and redis; some items are primarily stored in redis too, described below.
Messaging and events
The online and offline worlds are connected in a synchronous fashion by callto the primary data stores, transient/logging systems and in an asynchronous way using rabbitmq to queue up events that have happened like "a user dugg A Story" or jobs to perform such as "Please compute this thing ".
Batch and asynchronous systems
When a message is found in a queue, a job worker is called to perform the specific action. some messages are triggered by a time based Cron-like mechanic too. the workers then typically work on some of the data in the primary stores or offline stores e.g. logs in HDFS and then usually write the results back into one of the primary stores so that the online services can use them. examples here are things like indexing new stories, calculating the promotion algorithm, running analytics jobs over site activity.
Data stores
Digg stores data in multiple types of systems depending on the type of data and the access patterns, and also for historical reasons in some cases
CASSANDRA: The primary store for "Object-like" access patterns for such things as items (stories), users, Diggs and the indexes that surround them. since the Cassandra 0.6 version we use does not support secondary indexes, these are computed by application logic and stored here. this allows the services to look up, for example, a user by their username or email address rather than the user ID. we use it via the python lazyboy wrapper.
HDFS: logs from site and API events, user activity. data source and destination for Batch jobs run with map-Reduce and hive in hadoop. Big Data and big compute!
Mogilefs: Stores image binaries for user icons, screenshots and other static assets. this is the backend store for the CDN origin servers which are an aspect of the front end systems and can be fronted by different CDN vendors.
MySQL: This is mainly the current store for the story promotion algorithm and calculations, because it requires lotsJOIN
Heavy operations which is not a natural fit for the other data stores at this time. However... hbase looks interesting.
Redis: The primary store for the personalized news data because it needs to be different for every user and quick to access and update. we use redis to provide the Digg streaming apiand also for the Real Time View and click counts since it provides super low latency as a memory-based data storage system.
SOLR: Used as the search index for text queries along with some structured fields like date, topic.
Scribe: the log collecting service. Although this is a primary store, the logs are rotated out of this system regularly and summaries written to HDFS.
Operating System and Configuration
Digg runs on Debian stable based GNU/Linux servers which we configure with clusto, puppetand using a configuration system over zookeeper.
More
In future blog posts we will describe in more detail some of the systems outlined here. Watch this space!
If you have feedback on this post or suggestions on what we shocould write about, please let us know. This post was written by Dave (@ dajobe ).
This cocould be considered a followup to the how Digg Works post from 2008 describing the earlier architecture.