On the day of the rush Pinboard ran on dedicated hardware: a large web server connected to a larger MySQL database server with two MySQL slaves, and a more modest third machine for background tasks. The author describes the site as a thin wrapper around tuned database queries, with no application caching.
Near: we had a big web server connected | Near: the two MySQL slaves were falling steadily | Near: not much more than a thin wrapper
Figures, as the source states them
Figure
As stated
Note
Where
Web traffic seen on the shared web server during the rush
50 hits per second
Approaching; about twenty times the usual level; the server also hosts another site
Imports of new users' bookmarks backed up for hours because one bloated table took most of every write
pinboard-2010-delicious-exodus#f1at corpus version 26a1b3a7e3dd
Trigger
On December 16, 2010 a slide from a Yahoo all-hands meeting reached the web showing Delicious, Pinboard's much larger competitor, in a group labelled sunset. Thousands of new users signed up, each uploading an export file of bookmarks.
Near: showed a slide with a couple of Yahoo | Near: each arrived clutching an export file
How it failed
Within half an hour imports were backing up, writes were consuming all of the database's I/O and both MySQL slaves were lagging further and further, at 80 bookmark writes per second. Much later the cause was found in the tags table: a fixed-length char(255) utf8 column made MySQL use 765 bytes per tag, the table had grown past 80 GB, and adding to it and updating its index took three quarters of the write time for each bookmark.
Near: I saw that imports were backing up | Near: MySQL had to use 765 bytes per | Near: consumed three quarters of the write time
Why defences did not hold
The author had never thought to test the database under write load, because heavy writes seemed the last thing the site would face. He had also forgotten the column choice, and had not worked out why the tags table was so slow to load from backup.
Near: never occurred to me to test the database | Near: I so thoroughly forgot about it
Impact
Imports took over six hours by midnight and about ten hours at worst. With background writers switched off, new users had no tag cloud, tag auto-completion or suggested tags, wrong bookmark counts, and no search of bookmarks under a day old.
Near: at this point over six hours | Near: we fell about ten hours behind | Near: there was no tag cloud, no tag
Fix
During the rush the author switched off every non-essential service that wrote to the database, including the search indexer, and rewrote the tag cloud script to update only the counts that changed. Planned: he intended to run the ALTER TABLE that would fix the tags table on the Saturday night; the post does not say when it ran.
Near: I turned off every non-essential service | Near: only update the few counts that had changed | Near: Saturday night would be the perfect time
A crawl backlog of about two million bookmarks built up behind a crawler that ran one process per server
pinboard-2010-delicious-exodus#f2at corpus version 26a1b3a7e3dd
Trigger
Many of the new arrivals paid for archival accounts from the start, in which the site crawls and caches a copy of every bookmark. About two million bookmarks were left waiting to be crawled and indexed for full-text search.
Near: backlog of about two million bookmarks
How it failed
The crawler, like many other parts of the service, was set up to run as one process per server, so it could not work through the backlog quickly.
Near: set up to run in one process per
Why defences did not hold
The author had never taken the time to parallelize background tasks. He calls that a sensible trade-off when he made it, since it let him spend the time on something else.
Near: never taking the time to parallelize background
Impact
A significant group of new users had paid extra for a feature they could not yet evaluate, and the author feared a wave of refund requests.
Near: paid extra for a feature they couldn't
Fix
The author rewrote the crawler script so that several instances could run in parallel on each machine, and set up an EC2 image to work through the backlog faster. All the bookmarks were crawled by the Tuesday, the EC2 bill for December came to over $600, and he extended the refund window by seven days and gave everyone a free extra week of archiving.
Near: rewrite the crawler script so that multiple | Near: EC2 bill for December came to over | Near: giving everyone a free extra week
Code that read from a MySQL slave and wrote to the master assumed the slaves were minutes behind
pinboard-2010-delicious-exodus#f3at corpus version 26a1b3a7e3dd
Trigger
Under the import load the two MySQL slaves fell steadily behind the master.
Near: the two MySQL slaves were falling steadily
How it failed
In several places the code queried a slave and then updated the master. The author says that only works if being many hours out of date does not matter: he names the popular page as a place where that would do, and bookmark counts as one where it would not.
Near: I queried a slave and updated the master
Why defences did not hold
The author had assumed the slaves would stay within a few minutes of the master.
Near: I assumed slaves would be within a few
Reviewer's notes
The post lists this among the things that were plainly wrong and reports no fix. It does not tie any particular user-visible error to the stale reads, so impact is empty.
Give a simple site far more hardware and memory than it needs, and build no application caching
pinboard-2010-delicious-exodus#d1at corpus version 26a1b3a7e3dd
Chosen
The author rented dedicated HP blade servers with very large amounts of memory from Digital One, a small Swiss host, so that the data of about two thousand active users sat inside a much larger database server, and built no caching layers into the application.
Near: I found Digital One, a small Swiss | Near: our two thousand active users
Rejected
Layers of application caching designed in from the start. The author had just left Rails consulting and wanted to avoid what he saw as overengineering.
Near: really wanted to avoid this kind of overengineering
Reasoning
His view was that in 2010 a simple enough website could run very fast with no caching if given enough hardware. He also puts the overprovisioning down to his own laziness.
Near: could run ridiculously fast with no caching | Near: I had overprovisioned Pinboard with hardware
Outcome
The author says that with this much room given to MySQL, users and visitors could page through bookmarks without the server noticing them. He calls that the good news; the bad news was that he had never thought to test the database under write load.
Near: without the server even noticing they were | Near: never occurred to me to test the database
Reconfigure Apache and put pound in front of it after a news link slowed the shared web server
pinboard-2010-delicious-exodus#d2at corpus version 26a1b3a7e3dd
Chosen
Peter reconfigured Apache and installed pound on the web server, in about an hour, so that it could absorb the traffic.
Near: reconfiguring Apache and installing pound
What forced it
In September 2010 a link from the CNN homepage to the Bedbug Registry, which shares a web server with Pinboard, brought about 45 hits per second and made the server very slow.
Near: drove a comparable volume of traffic
Outcome
Three months later the same web server took traffic approaching 50 hits per second during the Delicious rush and stayed reachable and responsive, while other parts of the service came under heavy strain. The author credits this change for it, and reports that the median time to display a page stayed below a third of a second even at the worst of the traffic.
Near: web traffic was approaching 50 hits/second | Near: ran like a champ throughout the Delicious | Near: median page display times under a third