5. Simplicity of Single Component Services
• I can’t remember if that getter function takes 100ns or 100ms. - Said no
engineer ever
• Should I try to model this server request as a “remote procedure call”?
• 6 orders of magnitude difference!
• My front-side bus fails for only 1 second every 17 minutes! - Said no
engineer ever
• 99.9% availability
• Our internet only supports .NET. - Said no engineer ever
• Do we need an SDK?
6. "A distributed system is at best a
necessary evil, evil because of the extra
complexity...
An application is rarely, if ever, intrinsically
distributed. Distribution is just the lesser of
the many evils, or perhaps better put, a
sensible engineering decision given the
trade-offs involved."
-David Cheriton, Distributed Systems Lecture Notes, ch. 1
18. Which Architectures Featured…
1. Low entry-barrier
2. High performance in the face of distributed state
3. Huge (Internet) scale
4. Extensibility/evolvability (backwards compatibility)
19. Uniform Interface
1. Uniform identification of resources
2. Uniform resource manipulation
3. Representation separate from the identity
4. Hypermedia as the engine of application state
5. Self-descriptive messages
25. SDK Anti-pattern
Where's my SDK?
"A REST API should spend almost all of its descriptive effort in defining the media
type(s) used for representing resources and driving application state... [Failure here
implies that out-of-band information is driving interaction instead of hypertext.]" - Roy
Fielding
26. Casserole Anti-pattern
POST /groups HTTP/1.1
Content-Length: 1234
ObjectType: json
{
method : "UPDATE",
id : "123"
authToken : "abc123",
object : {
group : {
...
}
}
}
HTTP/1.1 500 Internal Server Error
Content-Length: 456
{
cacheTime : 0,
status : "authorization failed"
}
32. Uniform Interface: Error Codes
• 400s vs 500s
• Safe to retry?
• Cacheable (if no Cache-Control header present)?
• Does the client need to modify the request?
34. Uniform Interface: Content-Type Negotiation
Request header: Accept
Content-Types accepted by client
Accept: text/*, text/html, text/x-vcard, application/json
More specific types take precedence.
Server responds with 406 Not Acceptable if it does not support the requested media
type(s).
Server responds with 415 Unsupported Media Type if it does not support the request
entity’s media type.
35. Uniform Interface: Authentication
How does a server prevent unauthorized access?
1.
Authorization: Fooauth abc123=
2.
Authentication-Info: mytype
RFC 2617
Over-engineered narrowly-defined mumbo jumbo?
36. “The central feature that
distinguishes the REST
architectural style from other
network-based styles is its
emphasis on a uniform
interface between
components.”
37.
38. “WOW
My system has
too much
uniformity, loose
coupling, and
performance.”
-said no one ever
Multiple nodes computing on inconsistent state with regular communication failures present entirely different challenges than those computer science students face in the classroom writing DFS algorithms.
Idea:
Nothing’s more familiar to programmers than reading from and writing to memory? We access variables all day long. Why not make distributed state access look like simple memory access? We can use modern operating systems’ support for virtual memory to “swap in” memory that is located on another machine.
Problem:
How often do you go to access a variable and can’t because a section of memory is “down”?
How do you provide a mutex to parallel threads of execution?
How can the distributed memory layer be efficient when it has no knowledge of the application?
Idea: Next to memory access, nothing’s more familiar to programmers than functional calls. Can we make distributed state transfer look like a simple procedure call? SOAP!
Problems:
How often do you retry a method call because the JVM failed to invoke it the first time?
Why does incrementing a value take 100 milliseconds?
Why does your internet only support .NET and PHP (stub compiler/SDK)?
Idea:
Easy network file sharing.
NFS, AFS, GFS
Works great for files.
Idea:
Easy network file sharing.
NFS, AFS, GFS
Works great for files.
Idea:
How could you mooch bandwidth from universities and avoid infringement lawsuits at the same time?
Problems:
Mooching resources is a great business model but a terrible architecture if that’s not what you’re going for.
Idea:
I have so much state I don’t want to transfer it all in a single response.
This is something I first learned reading Richardson & Ruby’s insightful “RESTful Web Services” book. There’s really nothing special about web services.
HTTP is an application layer protocol. A common mistake that results in brittle, RPC-style web services is the use of HTTP as a transport layer for some other homegrown application protocol.
At Lucidchart we’re moving toward the REST architectural style, and one of the reasons is that it gives us an adaptable and evolvable architecture.
In the year 2000 Roy Fielding published his dissertation “Architectural Styles and the Design of Network-based Software Architectures”. In it he studies various architectural styles and analyzes why the web was so successful.
Roy surveyed these application architecture designs to discover which were effective at four specific goals:
Low entry-barrier
Distributed hypermedia
Internet-scale
Extensibility
Quickly summarizing three of the goals:
1. Looking at the goal low barrier to entry we see it is updated and managed by various entities independently, using many platforms, and being highly available to content authors and managers even when some pieces are down.
2. Hypermedia requires that presentation and control info be transferred to and from a client. Roy analyzed why the web is so successful at creating a performant application with hypermedia.
3. The Web’s accomplishment in achieving internet scale is incredible.
The final goal of extensibility is where we’ll spend the rest of our time.