Gourmet Coffee Geek
Author: admin Post Date: May 27 2011Y
ou know you’re a geek when going to
the coffee shop gets you thinking about
interaction patterns between loosely
coupled systems. This happened to me
on a recent trip to Japan. One of the
more familiar sights in Tokyo is the numerous
Starbucks coffee shops, especially around
Shinjuku and Roppongi. While waiting for my
“Hotto Cocoa,” I started thinking about how a
coffee shop processes customer
orders. As a business, the coffee
shop is naturally interested in
maximizing order throughput,
because more fulfilled orders
mean more revenue.
Interestingly, the optimization
for throughput results in
a concurrent and asynchronous
processing model: when you
place your order, the cashier
marks a coffee cup with your order and places
it into a queue. This queue is literally a line of
coffee cups on top of the espresso machine.
The queue decouples the cashier and barista,
letting the cashier continue to take orders even
when the barista is backed up. It also allows
multiple baristas to start servicing the queue
if the store gets busy, without impacting the
cashier.
Asynchronous processing models can be
highly efficient but are not without challenges.
If the real world writes the best stories, then
maybe we can learn something from Starbucks
about designing successful asynchronous messaging
solutions.
Correlation
For example, the asynchronous processing
model means that drink orders aren’t necessarily
completed in the same sequence in which they
were placed. This can happen for two different
reasons. First, multiple baristas might be processing
orders using different equipment. Blended
drinks usually take longer to make than drip coffee,
so a drip coffee ordered last might be delivered
first. Second, baristas can make multiple
drinks in one batch to optimize processing time.
As a result, Starbucks has a correlation problem.
Drinks are delivered out of sequence and
must be matched up with the correct customer.
Starbucks solves the problem with the same
“pattern” we use in messaging architectures—
they use a
correlation identifier.1
In the US, most
Starbucks use an explicit correlation identifier
by writing your name on the cup and calling it
out when the drink is ready. In other countries,
they often correlate by drink type. The correlation
issue became very apparent in Japan, where
I had difficulties understanding the baristas calling
out the drinks. My approach was to order
extra large “venti” drinks because they’re uncommon
and therefore easily identifiable—that
is, “correlatable.”
boake moore