โ Back to Amazon API Gateway
๐๏ธ Amazon API Gateway: cheat sheet
๐จ The analogyThe service counter of a big store: it checks each shopper's card, keeps the queue moving and points them on.
๐ The regular explanationA managed front door for APIs. API Gateway matches each request to a route, checks who is calling, applies throttling, and forwards the request to an integration such as a Lambda function or an HTTP backend.
- Ana walks into the store with a slip asking to order a toy. She goes straight to the service counter, not into the back rooms.
- The counter finds the line in its department guide for new orders and passes the slip to the Toy department.
- The Toy department writes its answer, and the counter hands it back to Ana.
- Next Ana asks about some shoes. A different line in the guide sends that slip to the Shoe shop next door.
- Then Ana asks for something that isn't in the guide at all. The counter says no itself, and nobody in the back is bothered.
- The counter passes Ana's slip to the Toy department exactly as she wrote it, with every detail on it.
- The department fills in the whole reply slip itself, how it went and what to hand back, and the counter passes it on unchanged.
- Now Ana wants a suit altered while she waits. The tailor starts work, and the counter waits with her.
- After about half a minute the counter gives up and tells Ana "no reply in time". The tailor is still sewing, though.
- Better to take the job, hand Ana a collection ticket straight away, and let the tailor finish in their own time.
- Ana shows up at the trusted card desk and gets a stamped loyalty card.
- The counter checks the stamp itself, without phoning anyone, and passes Ana's slip through.
- Ben has no card at all. The counter turns him away at once, and the Toy department never hears about it.
- Cancelling an order has tricky house rules, so the counter phones the store manager, who says Ana may go ahead.
- The counter jots down the manager's answer, so when Ana comes back within a few minutes it doesn't need to phone again.
- Sam's shop shows its trade card. Its allowance is five requests a second and a thousand a day, and this one goes straight through.
- Then Sam's shop rushes in with far too many requests at once. Its trade card allows a short rush, so a few get through, and the rest hear "too busy, try again".
- Lee's shop has its own trade card and its own allowance, so it still gets served while Sam's shop is told to try again.
- By evening Sam's shop has used all thousand requests for the day. It's turned away until tomorrow.
- But the trade card is plain card. Anyone who copies it is counted as Sam's shop, so the counter still needs stamped loyalty cards or the manager to keep strangers out.
- The store planner prints the first department guide, copy 1, and hangs it behind both counters.
- The planner adds a new line to the guide and prints copy 2, but hangs it only at the trial counter.
- Copy 2 works at the trial counter, so the very same copy goes up at the main counter.
- Copy 3 goes straight to the main counter without a trial. It sends shoppers' slips to the wrong departments.
- Easy to fix. The planner takes copy 2 from the file and hangs it back up at the main counter.
- Another shop's web page wants to take something out of a basket. Its chaperone asks the counter first, "do you serve requests from this shop's page?"
- The counter knows the answer, so it replies itself and doesn't bother the Basket department.
- Now the real request goes through. The reply comes back with a "welcome" note, so the chaperone hands it to the page.
- At a full-service counter that just passes slips straight through, the department must add the "welcome" note. Here it forgets, so the chaperone throws the reply away.
- Ana rings the counter and keeps the line open. The counter gives her line a number and tells the Gift list department a new line is open.
- Ben rings too, and his line gets its own number. The department writes both numbers down.
- Ana says "add a teddy to the shared gift list". The counter passes it to the department along with her line number.
- The department tells Ben through the counter, down his open line, without Ben asking anything.
- Ben then stays silent for ten minutes, so the counter hangs up his line and tells the department.
๐งฉ Key questions
- The tailor takes two minutes to finish an alteration. What does Ana hear at the counter?
- After about half a minute, "no reply in time", while the tailor keeps sewing. The counter only waits about half a minute, so long jobs should start with a quick collection ticket.
- Sam's shop keeps its trade card secret. Is that enough to keep strangers out?
- No: a trade card is easy to copy and only counts requests, so the counter also needs staff cards, loyalty cards or the manager. Anyone holding a copied trade card is served as Sam's shop.
- Copy 3 of the department guide sends slips at the main counter to the wrong departments. What's the quickest fix?
- Hang copy 2 back up at the main counter. Every printed copy stays on file, and the main counter only changes when a copy is hung there, so going back is just hanging an older one.
- At the full-service counter, which passes slips straight through, the Basket department's reply comes back without a welcome note. What does the chaperone do?
- Throws the reply away, even though the department did the work. When the counter only passes slips along, adding the welcome note is the department's job.