Feedbin's primary servers are physical machines at SoftLayer, in a data center in Washington D.C.: a Postgres database server with a hot standby, three Rails web servers and two Sidekiq background workers, with cloud servers there for two nginx load balancers and memcached. All feed refreshing runs in another data center, at DigitalOcean, on a Redis instance and ten Sidekiq instances.
Section: The Bare Metal | Section: The Cloud | Section: The Data Center
Components
Component
Role
Where
Database server
Postgres 9.2.4 on a physical machine with 64GB of RAM and four 800GB SSDs in RAID 10, plus separate disks for the write-ahead log. A similarly configured hot standby follows it, write-ahead log files are shipped to S3 constantly, and a base backup is taken nightly. The author thanks the team at Command Prompt for setting it up.
Near: Postgres 9.2.4 on Ubuntu 12.04.2 LTS | Near: The database has a similarly configured hot standby | Near: the team at Command Prompt for setting
Web servers
Three physical machines running Nginx in front of Unicorn and Rails 4.0.
Near: Nginx in front of Unicorn running Rails
Background workers
Two physical machines running Sidekiq Pro. They import the new entries that the feed refreshers find.
Near: Background Workers x 2 | Near: imported by a background worker running at SoftLayer
Load balancers
Two cloud servers running nginx that terminate SSL and balance load. Both are in use at once, through Active-Active DNS failover at Route 53, which hosts the DNS.
Near: There are two load balancers running nginx
Memcached
A 4 GB memcached instance on a cloud server at SoftLayer.
Near: There is also a 4 GB memcached
Feed refresh queue
A 16GB DigitalOcean instance running Redis 2.6.14, to which the refresh job is scheduled and which holds the ids of entries already seen.
Near: The refresh job gets scheduled to a 16GB
Feed refresh workers
Ten 2GB, 2 core DigitalOcean instances running Sidekiq Pro. Each job fetches a feed with HTTP caching headers, parses it, checks each entry's id against Redis, and queues new entries for import at SoftLayer.
Section: The Cloud
Figures, as the source states them
Figure
As stated
Note
Where
Usable SSD space on the database server
1.6 TB
About; capacity, not data stored
Near: for about 1.6TB of usable space
Memory of the database server
64 GB
Near: RAM: 64GB
Feed refresh worker instances at DigitalOcean
10 instances
Each 2GB with 2 cores
Near: There are 10 2GB 2 core instances
Entry ids in the example of Redis key distribution
20,000,000 ids
The example the author gives; about 1,000,000 Redis keys hold them
Near: For 20,000,000 ids only about 1,000,000 redis
Redis keys created for 20,000,000 entry ids in the author's example
1,000,000 keys
About; for 20,000,000 ids
Near: For 20,000,000 ids only about 1,000,000 redis
Put the database, web and worker tiers on physical machines because the workload is bound by I/O
feedbin-2013-full-metal-hosting#d1at corpus version 26a1b3a7e3dd
Chosen
The primary servers are physical machines at SoftLayer: the Postgres server with SSDs in RAID 10 and its hot standby, three web servers and two background workers. Cloud servers are kept for the load balancers and memcached.
Section: The Bare Metal | Section: The Cloud
What forced it
Feedbin is heavily I/O bound, and the author says cloud servers were not adequate for much of its functionality.
Choose a Washington D.C. data center for latency to both United States and European customers
feedbin-2013-full-metal-hosting#d2at corpus version 26a1b3a7e3dd
Chosen
The SoftLayer data center that holds Feedbin's primary servers is in Washington D.C. Feed refreshing runs in another data center.
Section: The Data Center | Near: All feed refreshing is done in another
Reasoning
Of the options, it seemed to have the best latency between the US and Europe. Most customers are in the US, with Europe close behind, the U.K. and Germany in particular.
Run a Postgres hot standby and ship write-ahead logs to S3 with a nightly base backup
feedbin-2013-full-metal-hosting#d3at corpus version 26a1b3a7e3dd
Chosen
The database has a similarly configured hot standby, kept with PITRtools. Write-ahead log files are shipped to S3 constantly and a base backup is taken every night with wal-e.
Near: The database has a similarly configured hot standby
Refresh feeds in a separate data center on cheap virtual servers that are quick to turn on and off
feedbin-2013-full-metal-hosting#d4at corpus version 26a1b3a7e3dd
Chosen
All feed refreshing runs at DigitalOcean. The refresh job is scheduled to a Redis instance, and ten Sidekiq Pro instances take jobs from it. A job fetches the feed using HTTP caching headers, parses it, and checks each entry's id against Redis. A new entry is converted to JSON and put back into Redis as a Sidekiq job, which a background worker at SoftLayer imports.
Section: The Cloud
Reasoning
The author says DigitalOcean's virtual servers are both low cost and high performance and quick to turn on or off, and that the refresh job is simple but has to run as fast and as much in parallel as possible.
Near: They provide low cost AND high performance | Near: needs to run as quickly and as parallel
Detect entries already seen with sha1 ids bucketed into Redis hashes by their first five characters
feedbin-2013-full-metal-hosting#d5at corpus version 26a1b3a7e3dd
Chosen
Each entry gets a unique id, a sha1 of a few of its attributes. After import the id is stored as a field of a Redis hash whose key ends in the first 5 characters of the id. The author's example is that 20,000,000 ids need only about 1,000,000 Redis keys.
Near: A unique id for an entry is | Near: For 20,000,000 ids only about 1,000,000 redis
Rejected
Storing the ids as a Redis set. In the author's trial it took more than twice the memory.
Near: storing the keys as a redis set
Reasoning
Bucketing spreads the ids evenly enough over the hashes to benefit from the memory efficiency of Redis hashes. The author tried a few other data structures and found this the most efficient.
Near: take advantage of redis hash memory efficiency