The refrain "automate all the manual work!" is thrown around many tech startups with reckless abandon. And when engineers do, large amounts of effort are often spent with little to no gain. Sometimes, it's because the difficulty to automate was underestimated, so it can't be done.

XKCD 1319. Automation is more difficult than one might expect.

Other times, when the effort to automate a task costs more than the effort to simply perform the manual work, the victory can feel hollow.

XKCD 1205. Increasing efficiency saves time only if the time spent optimizing is less than the time that would've been spent doing the task. 

But sometimes, automation is done properly, and the gains are exponential. The US postal service exemplifies this perfectly.

The first American post office was built in a Boston tavern in 1639, and a formal federal postal service was established in 1775. Given the century, it should come as no surprise that mail delivery used to be a completely manual process that required human labor and oversight at every stage. However, today's United States Postal Service sorts and delivers over 400 million pieces of mail daily. Handling that enormous amount of traffic was only made possible by embracing automation.

How mail delivery works

The USPS follows a hub-and-spoke architecture, with a total of 22 network distribution centers (NDCs) set up as hubs around the country to sort and distribute mail in bulk. When mail first enters the system, whether it's a letter dropped off in a collection box or a parcel handed directly into the hands of a post office employee, it is sent to the nearest NDC. There, it is oriented correctly, checked for postage, and sorted into pallets of bins that are transported to other NDCs closer to the mail's final destination. Those NDCs then unpack the pallets and distribute the mail to local post offices. Finally, carriers deliver the mail the remaining distance from the post office to the mail's final destination.

Even if mail is being delivered down the street, it will still visit the nearest NDC first to be validated and sorted before being delivered. And while this may seem inefficient, note that this design optimizes for the most common use cases and allows US residents to send mail across the country in a matter of mere days. Impressive!

The system's success is apparent in the sheer volume of mail delivered too. In the 1920s, the postal service delivered ~15k pieces of first-class mail each year, but by 2000, that amount was over 100k! To account for the increased volume, the USPS resorted to automation.

How the USPS uses automation

Today, NDCs use a facer-canceler machine that automates many of the tasks that used to be manual. These machines are able to orient mail so that they all face the same way and to validate postage using cameras that can detect the UV ink in stamps. They then add postmarks to cancel stamps so that the stamps can't be reused. Any letters without stamps are removed from the machine for manual review, but this is rare.

A Transorma (transport and sorting) machine then uses OCR to read destination addresses and sort mail into large bins based on which NDC they should go to next. Barcodes that encode destination ZIP code and bin information are automatically added to each individual piece of mail, and they're added to the bins and pallets as well. This way, when pallets are moved from destination to destination, their barcodes can be scanned to efficiently update the location associated with all their contents. The setup enables customers to track their mail without the NDC needing to sift individually through each piece of mail that arrives onsite.

Sometimes, OCR will struggle with messy handwriting. Addresses that can't be read are photographed for human review. The images are sent to remote encoding centers so that people don't need to be onsite.

NDCs aren't the only locations that rely heavily on automation. Once mail has been distributed to local post offices, these locations then use their own sorting machines to arrange mail in walk order for each carrier's route, i.e. the mail is ordered based on the path that the carrier is known to take when delivering mail. Carriers no longer need to come into the post office at early hours of the day to sort their mail manually before going out to deliver it.

Of course, the USPS still relies heavily on manual effort in some parts of the delivery pipeline, e.g. letter carriers are still needed to deliver mail the final leg of a route. However, I suspect that even this remaining human interaction will disappear over time. Delivery by drone or self-driving vehicle is just around the corner and probably something we'll see become a regular occurrence in our lifetime!