Mental Models204 cards · 12 fields

Mental Models/Computing & Information

End-to-End Principle

端到端原则

Only the two ends can finally confirm whether the job came out right.

When you chat on WhatsApp, a line of small print sits at the top of every chat: messages are end-to-end encrypted, and no one outside the chat, not even WhatsApp itself, can read them. Since April 2016 this encryption has been the default. Your phone first scrambles each message into gibberish nobody can make sense of; it passes through the servers, and only on the other person's phone is it turned back into words.

If only the stretch from your phone to the server were locked, each message would be unlocked at the server before being passed on, and both the company's staff and any hacker who broke into the server could see what it said. Now the servers still pass on every message, but they don't hold the key that turns it back into words.

The result "only the other person can read this" can be guaranteed only by the two phones. The keys are in their hands alone, and no server, however reliable, can stand in for them. It's the same with keeping secrets, delivering things or sending files: whether the job got done has to be vouched for by the two ends.

Under the end-to-end principle, whether a box arrived in good shape has to be checked between the sender and the receiver. You mail a box of 12 glasses to a friend in another city. The pickup, the sorting hub and the delivery each stamp it: packaging intact. Your friend opens the box and 3 are broken. None of the three stamps lied: each stop only looked at the outside of the box. You counted 12 before sending, your friend counts 9 unbroken, and when the two counts are compared, the 3 broken ones come to light.

Three stamps say intact, the ends count 3 short
Compare12 sentYou countedPickupIntactHubIntactDeliveryIntact9 arrivedFriend counted
Compare12 sentYou countedPickupIntactHubIntactDeliveryIntact9 arrivedFriend counted

Each stop answers only for its own stretch, and no stamp is wrong. You counted what you sent, your friend what arrived; compare the two and the gap shows.

Every stop along the way reports no errors, and the last step can still go wrong

You send a contract to a client. On the internet the contract is cut into many small pieces to travel, and each piece is called a packet. The network delivers every packet correctly, but the client's computer corrupts the file while writing it to the disk. Each device along the way only looks after its own stretch; nobody is watching the step where the file is written to the disk on your behalf.

When the two ends check against each other, a failure gets fixed

The sender works out a checksum from the original file; if the file's contents are off by even a little, this number comes out different. After saving, the receiver reads the file back off the disk and works the number out again. If it doesn't match, it asks the sender to send again; only if it matches does it report the job done. What gets checked is the file read back from the disk, so errors made while saving are caught too.

Whether checks along the way are worth it depends on the error rate

Cut the contract into 1,000 packets, and suppose each packet has a 1% chance of being damaged. On average 10 packets go bad on every send, and the chance that the whole file gets through right the first time is less than 1 in 10,000. With checks only at the two ends, almost every send would have to be redone in full; if each stretch along the way resends its own damaged packets on the spot, a great deal of redoing is saved. Bring the chance down to 1 in 100,000, and the whole file gets through right the first time about 99% of the time, so checks along the way save almost nothing. In both cases, the final check between the two ends still gets done.

The end-to-end principle helps most with results that only the two ends can see, such as a file saved to the disk, an order going through, or a chat that only the other person can read. The two ends can also only check the goal they agreed on. If a phone is hacked, the plain text of the chat still leaks out of the phone; if the original contract has a mistake in it, what arrives complete is still wrong.

If the result you need to protect sits entirely within one stretch, say you only worry about someone listening in on the office's wireless signal, then the two ends of that stretch are the ends, and encrypting that stretch is enough. And even with a check between the two ends, don't remove the checks along the way; otherwise every packet damaged on the wireless link means resending the whole file.

Design
When designing a mobile payment flow, decide "success" by whether the order shows up in the merchant's order system, not by the receipt the payment channel sends back.
Explain
An online course platform says "video uploaded successfully," yet the teacher finds it freezes at minute 3: the upload only confirmed that all the bytes arrived, and nobody played it through from the start.
Act
You set up monthly automatic payment of your parents' electricity bill, and the bank shows "direct debit set up." Only after the first payment has gone out, when you log in to the power company's account and see this bill marked paid, is the job done.
  1. At what point does this count as done, and who can see the result directly?
  2. After the steps in the middle report success, what step could still ruin the result?
  3. Of the information needed to judge the result, which is held only by the person who started it or the one who finally receives it? If it failed, who makes it right?

Securities

Seven of eight servers updated

On August 1, 2012, the American market maker Knight Capital switched on new trading code. A technician failed to copy the new code to one of its eight servers, and no second person checked. That machine started running old code that hadn't been used in years, and in 45 minutes it sent millions of orders into the market; the company lost more than 460 million dollars. The rollout was treated as done, but nobody had looked machine by machine at which version each one was running.

Medicine

Stop before the first cut

The schedule, the consent form and the medical record can all say which side to operate on, and surgeons still sometimes operate on the wrong part. From July 1, 2004, the Joint Commission, which accredits American hospitals, brought in a Universal Protocol: check before surgery; have the patient take part in marking the surgical site; and just before the first cut, the whole team stops to check the patient, the procedure and the site one last time. The patient knows which leg it is and the surgeon is standing at the table; with the people at both ends in the room, a mistake passed along through the paperwork can be stopped.

Personal life

Booking confirmed, no name on the room

A travel website says your booking went through, but when you get to the hotel front desk, there is no room under your name: the website's booking never reached them. Since then, after booking a room you always call the hotel directly and give your dates and name.

A hospital's medical records system has moved to a new database, and the migration tool reports table by table: "row counts match, no errors." After the switch, doctors find that for some patients the allergy history field in the new system is blank. The project team is redesigning the sign-off for the next migration.

What kind of sign-off would catch this kind of problem?

The owner of a small office worries that a neighbor is using the Wi-Fi without permission and could also pick up the data in the wireless signal. The office computers and router all belong to the company, and the internal wiring beyond the router runs in the server room, where outsiders can't get at it. The company also has a dozen or so old applications that nobody maintains and that can't be changed.

What should be done about this worry?

A same-city delivery platform wants a single rule: for every merchant's orders, the platform checks that "the goods and the address are correct" on the merchant's behalf before delivery, and merchants no longer need to confirm. The merchants include restaurants, pharmacies and florists.

What is the main problem with this rule?