Dropbox moved a desktop program that it ships to other people's computers. Instagram moved a web service that it runs itself, which meant the old and new versions had to share live data while both were in production. Both companies were working through the same break in the language, described in Python 2 to 3.
The main source is the keynote that two Instagram engineers, Hui Ding and Lisa Guo, gave at PyCon on May 20, 2017. The slides are published. The spoken detail comes from people who were in the room and wrote it down, and each such detail is attributed below.
Gen 1
Instagram's backend was a Python and Django application. One attendee's notes from the keynote record it as serving "over 400 million active users every day." A slide early in the deck puts the engineers' own view in capitals: "WE HAVE TAKEN OUR PYTHON+DJANGO STACK QUITE FAR."
It had already been through one upgrade of this kind. Another attendee, Mike Driscoll, noted the speakers describing a move from "Django 1.3 to 1.8" as well as from Python 2 to 3.
Python 2 was not failing. The slides give three motivations for leaving it, and none of them is an outage.
- Developer speed. The example on the slide is a function whose argument type is written in a comment. Python 3 can state the type in the code, where tools can check it.
- Performance. The web tier runs many more Python processes than the machine has processor cores, so requests compete for them. The team wanted more work done per core.
- Community. Attendee notes summarize it: "Community continues to make Python 3 better and faster."
The decision
The slides are unusually clear about what was rejected. They start with two constraints, each a single line: no "SERVICE DOWNTIME" and no "PRODUCT SLOWDOWN." Then they list three options and the reasons each one lost.
- A separate branch. "Branch sync overhead, error prone." "Merging back will be a risk." And a reason that is easy to miss: "Lose the opportunity to educate." Engineers who never see the new version do not learn to write for it.
- One endpoint at a time. Endpoints share common modules, developers would have to switch context, and separate pools of servers would need managing.
- Microservices. "Massive code restructuring," "Higher latency" and "Deployment complexity."
The choice is three words on its own slide: "MAKE MASTER COMPATIBLE." One codebase, on the main branch, able to run on either version, with feature work continuing in it throughout.
What happened
The plan on the slides has four phases, with estimates.
- Third-party packages, 3 to 4 months. The slide states a rule: "Rule: No Python3, no new package." Unused and incompatible packages were deleted and others were upgraded.
- Codemod, 2 to 3 months. The existing code was converted with an automated tool, modernize. The slide lists the kinds of fix it applied.
- Unit tests, 2 months. Tests ran under Python 3 against a list of those known to fail, and the list was worked down.
- Production rollout, 4 months. The rollout slide shows three steps of 0.1%, 20% and 100%, and names employees and developers as the first audiences. The Talk Python show notes describe the order as internal employees first and users gradually after.
The slides say plainly why the fourth phase was the longest. Under "UNIT TESTS: LIMITS" they list "Not 100% code coverage," "Many external services have mocks," and the one that mattered most: "Data compatibility issues typically do not show up in unit tests."
The clearest example was the cache. During the rollout, servers on Python 2 and servers on Python 3 read and wrote the same cached data. A Python 3 server saved data in the newest format it knew, and a Python 2 server reading it failed with "ValueError: unsupported pickle protocol: 4." Data written by Python 2 could fail in the other direction with a text decoding error. The two versions could share source code, and still could not share stored data until that was handled.
The other problems on the slides are the familiar ones from this language change: text and bytes, functions that now return one-pass iterators, and dictionaries that keep a different order from one version to the next, which changed the JSON the service produced.
One bug hid a result. An early measurement showed CPU instructions per request down 12% on Python 3, and capacity in requests per second up by nothing at all. An attendee's notes give the cause: a memory optimization was switched on by a check that "was never met in Python 3 as True because of unicode issue." The setting had been silently off.
The same notes record the end: "In Feb 2017, Instagram's stack completely dropped Python 2 and moved to Python 3 (v3.6)."
What made it work
- There was no second copy of the code. Every change went to one branch and ran on both versions, so the migration never had to catch up with the product.
- New debt was stopped first. The package rule meant the list of things to fix could only get shorter.
- The mechanical work was automated. A tool made the repetitive changes, which left people the problems a tool could not see.
- Production was the real test. A rollout that began at 0.1% let shared-data bugs appear while almost no one could be affected by them. This is running two systems on the same data, the hardest version of it.
- The team measured, and questioned a flat result. The capacity number that did not move led to a real bug.
The verdict
It worked. The slide headed "FEB 2017" shows the service on Python 3 and reports a "Saving of 12% (on uwsgi/django)" and a "Saving of 30% (on celery)." Driscoll's notes from the day identify the 12% as processor use and the 30% as memory. Caktus Group's summary of the keynote is that Instagram "performed an upgrade without any downtime and without slowing down the pipeline of new features."
The limits should be stated. The figures are Instagram's own, shown on slides at a conference. The accounts of the duration do not match exactly: an attendee wrote "about 10 months," while the estimates on the plan slide add up to between 11 and 13. The Talk Python show notes give a different figure for background tasks than the slide does. No source here gives the number of engineers involved or the size of the codebase.
What to take from it
- If the product cannot pause, the migration cannot have its own branch. Make the one codebase run both ways.
- Close the door before cleaning the room. A rule against adding new incompatible code costs nothing and stops the target moving.
- Expect data to be the hard part. Two versions of a program can agree on the source and still disagree about what is in the cache.
- Roll out in fractions of a percent. The first step should be small enough that a serious bug is a small event.
- Check the result that looks wrong. A saving that fails to turn into capacity is a finding, not noise.
Sources
- Hui Ding and Lisa Guo - Python at Instagram (PyCon 2017 keynote slides, PyCon's Speaker Deck account, published June 7, 2017) - the keynote as published by the conference: the motivations, the rejected options, the four-phase plan, the rollout steps, the problems and the savings
- Lisa Guo - Pycon2017 instagram keynote (slide deck, SlideShare) - the same 85 slides as uploaded by one of the two speakers, dated May 20, 2017 on the title slide
- Euccas Chen - How Instagram Moved to Python 3 (attendee's notes, June 16, 2017) - what the speakers said aloud: the daily user figure, the ten months, the cause of the capacity bug, February 2017 and the Python version
- Mike Driscoll - PyCon 2017 - Second Day (Mouse vs Python blog, May 21, 2017) - an attendee's notes from the day of the keynote: the earlier Django upgrade and which saving was memory and which was CPU
- Charlotte Mays - Python at Instagram, PyCon 2017 Must-See Talk 2/6 (Caktus Group, June 12, 2017) - a Django consultancy's summary of what the keynote showed
- Talk Python To Me, episode 116 - 10 top talks of PyCon 2017 reviewed (June 12, 2017) - show notes on the keynote: one codebase, testing under Python 3 while deploying Python 2, and the staged rollout
Last updated November 28, 2026.

