Skip to content


Why is Performance Monitoring so hard?

The Challenge

I was questioned recently about why we have so many tools to do monitoring.

Ultimately I think there is not one tool but there is one approach that will improve your people and your systems.

While it is true that different groups in the organisation need to ask different questions about the system at different times.

With the system constantly changing, individuals will need different tools to improve their "Learning Efficiency", and their general understanding of the system.

This must be balanced with the need for 1-n tools over the needs of the people's ability to react to system failures. Increasing their Learning Efficiency will improve their awareness of the system and should spread knowledge and reduce the Minimum Time to Repair(MTTR).

Also everyone should read Release It!

Overview

There are a lot of aspects to performance and monitoring and frequently concepts are mixed.

To keep it simple lets categorize them like this:

  • Current State - Instantaneous State based
  • Alerting
  • Historical Stats
  • Trace (System > Component > Request) ~ Vertical Profiling through technologies
  • Profiling - usually technology focused, like Java Profiling
  • Vital Signs

These have varying levels of intrusiveness; stickiness and probability of working when needed. They also have varying stakeholders, users, requirements, permissions that = red tape that slows you down when you most need the information.

There are lots of stakeholders that are usually focused on particular aspects at these times:

  • Production - Good Times
  • Production - Under Load Times (batch or interactive)
  • Production - Under Load and component Failures
  • Dev - Design/Architecture
  • Dev - Impl time
  • Test - Environment Issues - ala. Troubleshooting the Integration
  • Load Test Time
  • Soak Test Time

Complications

  • Heterogeneous Systems
  • Complex Async Interactions
  • Degradation of Monitored Metrics after installation
  • non use of metrics in good times = metrics may be misleading or untrusted in bad times
  • Either Not Enough or Too Many Metrics
  • When things start to fail, they do so in a non-linear fashion

I'm quite greedy when it comes to "Learning Efficiency", so I have many desired features of monitoring.

My Desirable Features of monitoring

  • Simple
  • Non-intrusive for standard operation
  • Minimal "observer effect"
  • Provide "Just Enough" Early Warning Alerts
  • Maximal use of current tools - don't hang your hopes on a new silver bullet
  • Choice in when to Increase accuracy by trading off intrusiveness
  • Tracing aspects
  • Decentralized - centralized lock down access inversely decreases the value and usefulness
  • Alerting and Notifications
  • Visual Trends

Simple is number one and because some information is better than none, I can frequently get by with simple command line tools.

Which Metrics to choose?

How do you reduce the signal/noise ratio. When there are 10000s of metrics to choose from.

For this I think we just have to go back to basics.

Your site exists for a reason, to serve traffic, to process some type of request.

Sites don't have a reason to exist if they are not involved in input/output.

Consider your system as a "small world" network. Concentrate on the Hubs and Connectors.

Start with your key flows:

  • end to end - human to human

Measure Requests/traffic:

  • Requests (bytes/counts/response types ok/fail) between servers (os, then app/jvm)
  • elapsed response times
  • resource utilisation - cpu/mem/io
  • queues/pools/quotas - finite resources and potential bottlenecks - more difficult, sensitive to changes.
  • effectiveness - seo analytics etc.

Add:

  • Alerts for outside boundaries

as well as having the extra info that affects the collected data and it's interpretation:

  • Influences on metric collection/recording, bug in metric sensor
  • Influences on interpretation and events - released xyz at this time...

Why is System wide monitoring so hard?

Suffers from lots of things: Conways Law, Tragedy of the Commons.

Too many stakeholders wanting different things from monitoring and not valuing the effort put into it.

The value of information is usually interpreted differently by many. Accuracy or correctness is not usually as important as age/timeliness and verifiability. Veterans usually place more importance on metrics, many juniors would not even consider of any interest.

Value is usually only seen by juniors when there are problems and the metrics can be directly/indirectly used go gain insight into a situation.

It is a very "hard sell" to setup an automated historical metrics monitoring system.

Centralised Management or tools are just too fragile, they suffer from bugs in too many places, too sensitive to change. Monitoring gets setup and people turn it off when it stops working etc. Spam generated from alerts get disabled...

When metrics fail or are erroneous, it requires discipline to prioritize and fix ahead of other seemingly more important issues.

Active vs. Passive Monitoring

Select metrics that will survive changes of software updates; source code releases, os updates; etc.

Select a process that will survive team changes and carry forward the underlying values and benefits of daily checklists.

Use distributed not centralized management, first. Forget trying to get a single tool etc. up and running with beautifully maintained stats. Difficult to maintain, untrusted, not resilient to change. Sometimes causes its own resource leaks.

The issue is more of a social problem, the technical problem is simple. Implement a daily checklist.

Ppl have this amazing property of responding to change, computers less so. Ppl attempting to program responding to changes often over complicate the situation, achieving the opposite effect, over the course of the project. As the brilliant mind of the original author is replaced by those less

Make Learning about your System a Cultural Trend

When Angry Monkeys are used for Good and not Evil. When used for good, it is usually referred to as following process or procedure.

When I was a young whipper snapper, bright eyed, enthused etc...

One of the best team leads, I've ever had, brought great discipline and process to our work.

It was the discipline of a daily checklist.

At first it was enforced by the Team lead, then as ppl rotated throughout the team, either of us would enforce that discipline.

Unfortunately others, do not always recognise the value.

Sometimes they may recognise the value when things go wrong. But then it is quickly forgotten.

When there are differences in the checklist or significant variations of some metrics, you need to be disciplined enough to track down the diffs.

Sometimes it may take weeks or months, but nonetheless, that level of knowledge is important for the team to learn.

Instill discipline into the culture, ppl can change faster than the technology.

The Way Forward

In our heterogenous environment, drop back to the simplest thing possible. Each app/node will have text logs. Generate events based on those logs.

That is the intent there are other tools as well, like splunk.com.

  • Simple Event Based Correlation - sec.pl
  • Provide "Just Enough" Early Warning Alerts
  • Maximise use of current tools
  • Monitor Rate of Change of metrics as well as State Based as dramatic rates of change of pending doom.
  • Ease comparison of metrics - Order of Magnitude trend differences, side by side comparisons, annotation of events of interest etc.
  • Interconnecting this monitoring data with your domain. Multipliers.
  • Cheap, adhoc and non-destructive tools should never get replaced by one centralized monitor

The "All singing all dancing Monitoring and Management System", may be possible in some companies, but for most I think it better to stop chasing your tails and put "people and processes" over "tools and technologies".

Things will go wrong

So make sure learning about your system is a priority.

Besides Preventative Maintenance or Daily/Weekly Checklists, make time to Learn your Fragile components or synchronous call chaings; your Rhythms and Multipliers.

See Release It for "Circuit Breaker pattern" and alike.

Multipliers within systems, always crop up, especially as a balance between reaction time and cost to develop properly. Key Entities or Seasonal Customer Traffic flow.

All this will help reduce your Minimum Time To Learn and your Minimum Time to Repair (MTTR) your System.

Post to Twitter Tweet This Post

Posted in Stability, Performance and Monitoring.

RESTful Architecture Style Distilled: Joe goes Jeans Shopping – Part Two (Realworld Experiences)

Desperate Times, call for desperate measures

Maybe it's time to just go to a real shop, the online ones were going to charge delivery anyway.

Well he has find one close by, lucky google maps has a convenient local search with a google maps directly in the search results.

It's a tough call, Joe is pretty lazy, but they are two blocks away and there are time pressures.

The nearest shop to him is "Le Small Fry Jeans".
Would have been good if they had a map on their lousy web page, he would have noticed how close they were earlier, like the embedded google maps mashup on "JeanStop".
They were difficult to find, even with a map.
Joe: enters the shop
Joe: I'm looking for some jeans
ShopAssistant #1: parle-vous francais?
Joe: (Thinking) Crap, well this is going to be difficult, if we can't communicate.
Joe: parle-vous anglais?
Joe: I can't even use a simpler and common communication mechanism (like pointing), because all their stuff is hidden away,if only there were a universal way I could tell her what I'm after.
Joe: discovers a printed catalog and gestures
ShopAssistant #1: ?? Puzzled look - shows him the front cover, only seems to be for female jeans.

Joe, finally gives up at this stage, reaches for his iphone and checks for nearast jean shops to his current location...

A chance discovery: "SlickJeanService"

Well today might be his lucky day after all. Just around the corner is another shop he didn't even see on his search results.

They must have been further down the page.

He enters.

Apparently in order to streamline their business process they have instituted a new protocol.

This will make the shopping experience faster, apparently...

Except Joe has to learn and memorise the new protocol/commands to GET what he is after.

It looks kind of like a Noodle Bar setup, you know there are 3 steps, first step is to pick your noodle type, second step is soup/laksa...

Well that is different thinks Joe, I don't really know what I want yet, I'd like it to be like my last pair, I don't even really know how to describe them, I just know what I like.

He'll give it ago. Inside there are more signs about how you can not deviate from this one path of conversation, any attempt to discuss with a Shop Assistant, results in redirection back to the beginning of the path.

He takes a step closer to the start line, it is a very busy store...
Oh Oh, trouble, there is a new set of instructions that don't match the large menu set of instructions, more reading.
They are in a process of further streamlining.
Joe looks like a deer in the headlights.
These instructions don't make a lot of sense...
Initially, Your Date of Birth to determine your Chinese Zodiac Animal is required and a combination of some secret formula will place you at some position in a queue

Joe is getting mad, he has to learn a different way of just getting into a queue, let alone work out how to ask for jeans when he can barely describe what he is looking for.

Too much thinking, must leave... Lucky every shop doesn't work like this, that is way too much work for lazy joe, on to the next shop...

Be careful what you ask for

The next nearest shop to him is "JeanStop".

There are three shop assistants serving the same number of customers.
Joe has to queue until one completes a sale
Joe: I'm looking for some jeans
ShopAssistant #1: Yes, you have come to the right place, we sell jeans
Joe: Great, Can you show me what have you've got?
ShopAssistant #1: That will take too long, give me some more information
Joe: Ok, I want some jeans, I'm a size 87cm, with a straight cut, I haven't decided about the wash or colour yet?
ShopAssistant #1: Wait right here, let me see if we have some....
ShopAssistant #1: Yes we have too many for me to bring out, can you refine your search
Joe: is thinking how should he phrase his question when the clock strikes 10:15. The shop assistant without a word, disappears out the back... Did he just go a coffee break?
Joe: Spins around to one of the other free shop assistants
Joe: I was looking for some jeans, I told that other guy what I was after
ShopAssistant #2: Sorry, I wasn't listening to your conversation, I don't know what you want, you'll have to start again
Joe: AAAAAAAAAAAAAAAAHHHHHHHHHHHHHH!!
Joe: starts again, but notices ShopAssistant#2 has a training badge on...
ShopAssistant #2: I understand all of your requests from prior conversations, except for that last one.
ShopAssistant #2: I will have to ask someone else, can you wait for ShopAssistant #1 to return from his break?
Joe: This guy is a dumb version of the real thing. He can only relay questions that he has found out from ShopAssistant #1.
Joe: Right now he wishes he had a url (/jeans/levis/501?style=stonewash&cut=straight&length=short) or even a picture in a catalog to point out to the guy what he was looking for.

He is tired of wasting his time and heads to the next shop...

All I want is a pair of jeans

Location: "HowMuchAreThoseJeansinTheWindow"

It is really busy in here there are about 4 to 1 customers to shop assistants.

At this shop however they are quickly flitting about between customers taking new requests and it isn't long before Joe gets some attention.

Joe: I'm looking for some jeans
ShopAssistant #1: Yes, you have come to the right place, we sell jeans, let me help you choose what you are looking for.
ShopAssistant #1: Here is our latest catalog, in it you will find -- starts to rattle off a list of stock...
Joe: Great, Well I need something in size 33inches
ShopAssistant #1: Yes, this way, tell me more. Do you like prefer any of these cuts; styles or lengths...
Joe: A few more back and forth conversations later...
ShopAssistant #1: Excuse me Joe, I must attend to another customer request, just flip open your catalog so you can let me know where we were up to when I get back.
Joe: Wow, the shop assistant started speaking Dutch and talking to another customer, they to have a catalog in hand, looks like it is in their language as well.
Joe: He looks around and sees another Shop Assistant using sign language. Those guys really know how to communicate
Joe: Does some more browsing by himself
ShopAssistant #3: Hi Joe, so what were you looking for?
Joe: Armed with the trusty catalog, points where he was last at so he can continue his conversation, but with a different ShopAssistant.
Joe: After a few more suggested options from ShopAssistant #3 and Joe finds what he is after.
Joe: GET those jeans.

So what does this have to do with REST anyway

Did Joe finally get his pair of jeans?

Well that doesn't matter too much, when we are here to talk about REST.

If you stuck to the script, you've already seen a lot of evidence that REST describes and some that it doesn't.

By far the best experience Joe had was at the last Location "HowMuchAreThoseJeansinTheWindow".

This shop embodied most of the important constraints of REST and it was this shop that seemed the most scalable, just like the architecture of the Web. Only a few Shop Assistants serving many customers.

The first enablers for this ability is for clients to be able to identify what they want (Universal Addressability), eg. Joe pointing his finger in the catalog will be understood by any of the Shop Assistants. Secondly our Shop Assistants are Stateless, that is they can suspend conversations with one client and switch to servicing another, without the need of them to remember anything specific to a particular client or conversation.

Stateful components make integration a complex and expensive proposition, see: "JeansRUS".

The other great thing about that shop, was the way the assistants guided the client, they always answered questions and gave a choice of other available options.

They also talked in a standard manner (Uniform Interface), unlike "SlickJeanService" that tried to force new ways of doing things for the sake of their one store.

If we combine these features we make it really easy for a client like Joe to talk to our Shop Assistants.

So all Joe needs to know is:
  • where the front door is
  • negotiate preferred content
  • how to ask questions
  • how to follow options

Stay Tuned

We leave Joe, with a new pair of Jeans.

See part one for RESTful Architecture Style Distilled: Joe goes Jeans Shopping- Part One (Online Experiences) .

Join us next time for Part Three when we dissect the story further.

Post to Twitter Tweet This Post

Posted in Uncategorized.

RESTful Architecture Style Distilled: Joe goes Jeans Shopping – Part One (Online Experiences)

For SEOers; developers; testers; web developers; BA's and CIO's.

REST has some tremendous benefits, but it's message is clouded. It's a message that I feel needs to be partly understood, by more than just developers.

Narrative, seemed a good enough form (I would have preferred comics). I was inspired by Dan North and friends(Simon Stewart) story about a guy buying pants from a WS-* like shop vs. a RESTful shop and How I explained REST to my wife.

In this Four part series, I'll attempt to simplify the ideas behind presented by Roy and others from his dissertation for a wider audience.

  • Part 1 - Online Experiences
  • Part 2 - Physical (Offline) Experiences
  • Part 3 - Summary
  • Part 4 - Further Technical Detail

This is tough, I will necessarily loose details, but the intent is not to mislead, only to introduce some examples and benefits of adopting a RESTful style.

If you are an SEOer; developer; tester; web developer; BA or CIO who wants to know more about REST and what the benefits and pitfalls are, then Read On.

The Problem - Joe needs some new jeans

So there was this guy called Joe, he really needed some new pants, to go with his Jacket. He was pretty tired from the night before, so checked online for some jeans shops.

Following a Friends Recommendation

He finds a url in an email, someone sent him about jeans.

The link is to the home page of "Jeans R Us"

The link isn't to a particular type and style of jeans.

There was this this other large box, promising stylish new jeans experience, but he needed to install some new plugin called Adobe Flash.

Well what's a few more minutes..................

Once that was running eventually a cool flash movie with animation that let him change all those options and get a 3D view of the jeans.

But as he uses the system he can't use the browser back button, the application seems to have it's own back button.

He tries another tab, that also isn't working like normal web sites.

It really doesn't work the same way as most web sites, it all happens on the one page.

The url never changes and that's why he can't even bookmark his favourite jeans choice.

Although they have their own custom way of doing favourite jeans, but you have to create a profile.

The site is just frustrating, time to checkout Google instead.

Once more, with purpose

So after giving up on that site.

Google had a few results for him to check out.

The 1st organic search result for the "Le Small Fry Jeans" store, had a link to a business directory web site.

It had stylish, well designed page with a street address and an email address.

BUT THAT WAS ALL!!!

Hmmm, the trading hours given on the website were different to the trading hours on the directory web site.

I wonder which one is actually updated regularly?

Second times a treat

Back to Google search results.

One of the sponsored links, "Jeans Mega Store" had a fantastic website.

This site seems really responsive, only parts of the page are updated when he made a selection.

He could enter in his size; select a cut and style; while seeing what is currently popular; there were also promotions for new customers.

There was a lot of a attention to detail, including: - a simple page with Trading Hours - store locations in a google map embedded on their own page.

The deals were pretty good, he browses.
Oops, made a mistake, tries to use the Back Button, it seems broken.
He is forced to work out how to undo what he did in their specialised interface.
Adds some things to his cart.
Now he is ready to checkout, this action switches him to a a secure site, with his previous selected products.
He enters in his credit card details.
He hits the "Proceed" button...

ARRGGGH!!

No Go - they have no stock, they only check after his credit card has been entered.

Well, screw that he says. He abandons the order.

This clearly won't do, Joe must have some new pants for tomorrow, or he may have to do some washing himself...

3rd times a charm

Back to Google search results.

The 2nd organic search result is for the "How Much Are Those Jeans in the Window" store, this one is styled purple, he has been there before. Well this store has been around for a while, it has a clean but simple interface, it is pretty fast.

The online html catalog has basic jean pictures, with a small number of options.

The online catalog in html also has links to a pdf catalog. That is great for offline viewing and formats nicely on the printer.

Hmm, he seems to remember going to this store once before, he bookmarked a link for a particular type of jeans.

He searches through his old bookmarks.

Hmm, "404 Page Not Found Error".

Well what does that mean, are the out of stock, is it no longer available or did they just revamp their website?

He only bought the last pair 3 months ago on the last washing day, they've probably just updated their website and now his old links don't work anymore.

Lets use the old faithful Back Button and continue.

After product selection and styles...

He clicks "Proceed with Order"; enters in all his customer details;

He is having doubts, will that be a good look?....

Just then the phone rings...

Distracted, he has a bit of breakfast, feeds the dog, gets back to his computer.

Has finally decided these are the right jeans for me.

He hits the "Buy" button....

The url looks like this: /order/1234?action=process&....

Foiled Again

He is rewarded with another Error Page. His session has expired, whatever that means. He hits refresh a few times, now it is asking him more questions, click ok; then give up.

Restarts his browser and goes back to the site.

Luckily the browser has history, they had a pretty long domain name, even if it was fairly easy to remember.

Ohh, something else is wrong. Part of the site is working, but every time he goes to do a search he gets some sort of "503 Server Error" now.

This online ordering, can be a real pain.

Stay Tuned

We leave Joe, staring at his terminal, pulling his hair out.

Join us next time for Joe goes Jean Shopping Part Two - In the Real World.

Confused: We haven't discussed REST at all yet, stay tuned for Part Two and Three, when we finally discuss how some of Joes experiences relate to a RESTful Architectural Style.

Post to Twitter Tweet This Post

Posted in Uncategorized.

Ode of an Architect – The Journey

It starts with self
while (alive == TRUE) mind.get(random(thoughts))
Thy subconscious is a fiesty, unpredictable partner
There are no original thoughts
Designs of economy and elegance
Are reluctantly released
Complexity will be contained
Clarity will come in time

I imbue visions and ideas
One team or one deliverable at a time
The journey is long and difficult
The rewards are many

Success made possible
By conveying understanding
Persistence and boldness
My allies include Clarity; reason and spikes

Reality intervenes
Tradeoffs will be forged
Intentional not accidental
The team understand the goal
Where we can take things next time

Helping others learn
Challenge and stimulate me
Together we light paths forward
Casting aside
Perceived constraints of the mind

Continuous improvements we make
Eliminating waste as we go
Alien to the unenlightened
Liberating to the energetic few

Mistakes and conflicts will occur
Choose battles and timing
Many opportunities to learn
Sometimes the master
Always a student
My appetite for learning
Grows with time

Custodians of the future
Expand your mind
Use many lenses
Choose your journey
Evolve your systems
Deliver value with vigour
Take action now

- Brett Dargan

Not sure where this came from, I had a slighly poetic moment, not in the rhyming sense ;)

Post to Twitter Tweet This Post

Posted in design.

JAOO 2009 – Brisbane

Another good event, great speakers, lots of language talks, agile, architecture, scalability, databases ala megastore. highlights for me, in no particular order.

  • Avi Bryant's new project, great eye candy had the crowd go "ooooooooohhh". When will an api be open to plug other data in???
    • Also nice talk on VM history, how we are working on VMs from algo's designed in the 80's. And the features or standard of VMs aren't available for all our favourite languages.
  • Tiersen , good intro to sharding and google approach to scaling out
    • liked the probability graphs
    • read chubby, logserve paper
    • higher level of jonas discussion, but jonas did refer to tiersen counter example
    • When the web came along, our apps were read mostly.
    • These days, social sites, are moving away from this scheme, to one of shared data. Some of that shared data is written to a lot. but it is updated, the majority of it is always inserts only.
    • write fan outs.
    • combine the two operations in one, so write + read all counters at same time
    • counter example too simple, can bypass optimistic locking as counter should be monotonically increasing
    • combine websites with fragments of data/entities with different shards and shard policies.
  • Jonas - great talk re Megastore
    • Treat everything as an insert, duplicates will occur make sure they are idempotent
    • Updates are a little harder, but what is an update really, when can you say it is actually done?
    • Confirmed for me that a current strategy i'm implementing is right and will work (well for two, maybe three nodes anyway).
    • To get to more will need a decent Paxos implementation, which takes smart ppl and time.
    • consistency, availability, entity groups and big table
    • web apps more read/write than before, lots of shared data, but mostly additions
    • consistency, reliability, storage, scalability and megastore scale, entity groups, transactionality, avoiding joins
    • consistency: user trust, none, eventual, entity group, global
    • consistency: "a harmonious uniformity of agreement among things or parts"
    • Sharding by entity groups.
    • storage vs. cost of loss
    • paxos vs. 2pc
    • papers jonas recommended: pat helland paper; jinquan dai, intel, james hamilton, MS
    • I have a lot more to say about this topic, as I cut my teeth on Oracle Performance Tuning and it's architecture, always providing a READ CONSISTENT transaction at a minimum, I use to think was a great idea, until I wanted to scale it further.
    • Disk Reads are about 10,000 slower than memory access, but not if you have to manage a lot of versions of different blocks in memroy. The overheads reduce the read in memory to ONLY 10 to 100 times faster than a disk read. That just isn't enough. See Milsap papers on Oracle scaling there are a number of them and James Morle's book on Scaling Oracle 8i which is a great book, the older print version can still be picked up as well
    • The approach of one single db instance creates new problems, now we need transaction logs and a hot standby and a DR data centre...
  • Nygard (Release It! )- i missed the first one due to a conflict <img src='http://brettdargan.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .
  • mike cannon-brookes - had to fill a tough set of constraints, but interesting story about atlassian.

  • Clemens
    • ms unified component thingy. simliar to osgi. Nice talk about issues with design, component composition and how all of IT boils down to composition of things at varying levels.
    • Discussion about component composition and how state is always a problem, yes.
    • Advocate of service use, not reuse as it should be used "as is"
    • I prefer service use over code/component, especially with a services developed with RESTful intentions
  • Dan North, telling project war stories based on experience and * observations of good architects * soa gone bad, wsdl

    • Listen, Listen, Listen
    • technical problems aren't the biggest issue, silo communication
    • replacement of tools sqlserver to oracle, not solving the real problem
    • the nameless quality
    • vision, inspiration, enabler
    • project shaman
    • empathise
    • self belief, a sense of conviction and humility
  • Joshua Bloch - great stuff
  • Eastman - apache mahut. Dirichlet clustering, hmm, that algorithm wasn't in Collective Intelligence

  • Douglas Crockford
    • javascript inspired by self, scheme, perl and java
    • prefer === over == doesn't do type coercion
    • he no longer uses ++ and -- anymore, implicated in buffer overflow exploits
    • lambda, dyn objs, loose typing and object literals.
    • refreshing to discuss languages and language features again
    • the memoizer example was good, check the slides for recursion usage
    • use functions to make objects
    • functional inheritance
    • be rigorous and use jslint

Other Comments;

  • Lots of cloud talks, very fluffy, but where was the discussion about SUN Cloud RESTful API
  • No REST, no erlang.

Books to checkout:

Post to Twitter Tweet This Post

Posted in General, Stability, Performance and Monitoring, Web, design.

RIMVR and HATEOAS: MVC+URITemplateAspects, LinkAwareModels and LinkTemplateProcessors

There has been a discussion titled [Jersey] Putting the RESTful "connectedness" around my existing Domain objects on the jersey mailing list that is starting up again.

I don't think I have confused HATEOAS with "connectedness", I have a reasonable understanding of resource state, application state and HATEOAS.

See http://www.stucharlton.com/blog/archives/000141.html and this discussion, http://tech.dir.groups.yahoo.com/group/rest-discuss/message/12497, which I see you have contributed to.

I think this final point made by Roy is pretty applicable here:

A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations. The transitions may be determined (or limited by) the client’s knowledge of media types and resource communication mechanisms, both of which may be improved on-the-fly (e.g., code-on-demand). [Failure here implies that out-of-band information is driving interaction instead of hypertext.]

My point is you can't adhere to the HATEOAS constraint, without providing links between resources so the server can guide the client to other application states.

I agree that forms are a better example for explaining state transitions, especially since resource state is likely to be changed by providing forms (as will the User Agent, as Roy mentions); or equivalent form templates/prototypes for other media types.
But to me providing forms or equivalents for other media types is a different and easier problem to solve.

I'm very interested in how to evolve existing systems; I want to leverage the vast islands of information that already exist.

I just want to do it in an elegant way from a code and a web perspective, including the fact that uri's shouldn't change.

RIMVR: MVC + URITemplateAspects; LinkAwareModels and LinkTemplateProcessor

URITemplateAspects; LinkAwareModels and LinkTemplateProcessor

In a standard, layered design, you would have these components (see Image):

1. Code-On-Demand
2. View
3. Controller
4-6. Contains the Proposed Abstractions
7. Model
8. Persistent Store - Db; file; jcr; webdav
9. Proxies

Here are some options I have for adding links around some existing system (there are likely more)

Due to the time constraints, the Pros, will be sparse.

Option 1: Add Links via Code-On-Demand.

Add links to my html page via javascript.
I could take my existing html representation and use dhtml to add links.

Cons:
* code-on-demand not available for all user agents or may be disabled
* Proxies can't cache the entire representation
* leak of possible application states to clients that don't need to know
* Detailed knowledge of resource and subresources required to provide "link rich" representations
* Alternative media types may require alternative languages or structure to perform add the links. ie. use of xsl for xml; javascript with svg.

Option 2: Add Links via Views

Cons:
* We all know this is bad
* Detailed knowledge of resource and subresources required to provide "link rich" representations
* different views/media types require the same logic and detailed knowledge of the model
* different views/media types may require some application state knowledge. an admin user may have other links than anon.

Option 3: Add Links via Controllers

Pros:
* Can handle the inclusion/exclusion of links depending on the current application state, regardless of the media type to respond with

Cons:
* Detailed knowledge of resource and subresources required to provide "link rich" representations

Option 4: Add Links via Models

Pros:
* Detailed knowledge of the model and related models belong in the Model

Cons:
* Detailed knowledge of resource links aren't the domain of the models
* Not all possible related models are likely to be represented; to balance performance with types of usage, often some relationships are not modelled, so as to not eager load, very large graphs etc.
* Links are very static, The "next available" application state, still needs to be determined in another layer, like Controller

Option 5: Add Links via Persistent Store

Store partial links in the db

Pros:
* Db driven, easy to update
* Tables have relationships
* easy adoption path
* easy to link to external resources, or resources outside your db schema
* easy to share links at db level, if several systems integrate at that level
* Good for sparse relationships.

Cons:
* Update to change a link, will not play nice with intermediaries nor "cool uris, that don't change"
* Not great for consistent dense relationships, you probably want to model that differently. So with a Parent Child relationship, you wouldn't want something in addition to existing foreign key relations, to redundantly specify that to get to the children of a parent you have a list of /child/xyz links. but by having that specified in the URITemplateAspect then you are managing that once, close to the data.
* Relationships are not always defined in Foreign Keys
* Links are very static, The "next available" application state, still needs to be determined in another layer, like Controller
* Only a partial solution for more dynamic aspect of determining what application states make sense, still needs to be done in another layer.
* May be invasive, links stored in columns or other tables, no good if you've got a locked down schema.

Thoughts

Models shouldn't have relationships to hardcoded resources, like "/resource/50", but they could have a semantic relationship to "/resource/{id}" or "/resource/{id};role={role}" under certain conditions.

There is a place for such LinkAwareModels (Component no. 5), as long as the links are isolated and only contain semantic relationships, they are not urls.

The Links from Models to Resources are isolated and encapsulated within its own abstraction; which gives us component no. 6 URITemplateAspects (maybe just simplify this to LinkTemplateAspect).

Possible "Application States" are dependent on the request, even though a request must be STATELESS, possible "Application States" may still be determined by the security access; restrictions of media-types or client, which should all be part of the request. If you do stuff with user roles, then make sure you encode within your url.

Component no. 4 is our LinkTemplateProcessor(s) and its responsibility is to evaluate URITemplates within the LinkAwareModels/entities and to determine appropriate state transitions based on the request.

This leads us to the final Option ( well, for this post ;) )

Option 6: Semantic relationships of a "Model to resources" definied via URITemplateAspect and a LinkTemplateProcessor to evaluate the relationships (URITemplates) and sub-entities to determine other "application states"

Pros:
* Detailed knowledge of the model and related models belong in the Model
* Detailed knowledge of the model to resource of interest is a concern isolated in the URITemplateAspects
* Any possible relationships to other resources can be defined
* Links are very dynamic. The possible state transitions can be determined by the LinkTemplateProcessor, but it can do so decoupled from the detailed relationships of the model to other resources.

The semantic relationships that are defined in the LinkAwareModels, can include uri and other attributes, like rel. The LinkTemplateProcessor can evaluate a lot of the current application state (but not all as the User Agent may have representations from other servers or representations that have been modified by Code-On-Demand) in combination with the semantic relationship to determine the ultimate value of the link to use (relative preferred, of course) and it can determine if that link is a valid state transition. Only if you are an admin do you see this link; or the link retains the current media-type used for this request; so a request for /country/AU.html includes links to cities.html, not just cities. The default negotiation might be something if that is not specified.

* The Processor can operate on objects, prior to rendering to a particular media-type, so if you have a single object model that can render to multiple media-types, you could have less code

Conclusion

What do you call, this, maybe Rich Interconnected Model View Resource RIMVR.
Rich in relation to having deep links within a resource representation and from the applicability of those links. That actual uri templates are evaluated late and with some context of the request and application state.

The use of these abstractions, in no way make an application RESTful, that is up to the developers, but hopefully by following some abstractions, like these we will get some clean code and some better understanding of RESTful APIs.

I have some old code, to show this working.
One day I'll get a chance to clarify terms and simplify the code ;)

Post to Twitter Tweet This Post

Posted in Patterns, RESTful, Web, design. Tagged with , .

Some comments on 101 Things I Learned in Architecture School

101 Things I Learnedin Architecture School

Some comments about a standard "architecture" book of one pager pearls of wisdom.

There is not much too this book, then again, "less is more" .

#21 - An Architect knows something about everthing. An engineer knows everything about one thing.

"An architect is a generalist, not a specialist. "

This is consistent with becoming a Generalising specialist.

#29 Being process-oriented, not product-driven, is the most important and difficult skill for a designer to develop.

I take "process-oriented" in this context to mean improving your own processes and not the general interpretation of burdensome processes.

Pragmatically this "process-orientated" statment is about focusing on the process of design and improving those skills, in place of speed of product development.

Another aspect on this is balancing learning efficiency with task efficiency, which Jason Yip mentioned in a recent presentation.

Tip #29 has nine sub points, here are a few of my favourites:

  • seeking to understand a design problem before chasing after solutions;
  • making design investigations and decisions holistically
  • working fluidly between concept-scale and detail-scale
  • making design decisions conditionally - that is, with the awareness that they may or may not work out as you continue toward a final solution; See also "Considerations in communicating the Intent of Design".
  • Knowing when to change and when to stick with previous decisions
  • Always asking "What If...?" regardless of how satisfied you are with your solutions.

#45 Three Levels of knowing

Simplicity
world view of the child or uninformed adult.
Complexity
the ordinary adult world view. An awareness of complex systems in nature and society but an inability to discern clarifying patterns and connections.
Informed Simplicity
an enlightened view of reality. It is founded upon an ability to discern or create clarifying patterns within complex mixtures. Pattern recognition is a crucial skill for an architect, who must create a highly ordered building amid many competing and frequently nebulous design considerations.

#16/26 - Parti and Changing Parti

"Parti derives from understandings that are nonarchitectural and must be cultivated before architectural form can be born."

Parti has been in "architecture" for a long time, it also gets mentioned in ux articles.

At its most ambitious, parti derives from matters more transcendent than mere archtiecture.

I like the abstract notions behind it.

#48 If you can't explain your ideas to your grandmother in terms that she understands, you don't know your subject well enough.

"Some architects, instructors, and students use overly complex (and often meaningless!) language in an attempt to gain recognition and respect.
Try not to let them get away with it and whatever you do don't imitate them."

When this happens to you, be critical, instead o blind obedience, practice selective observerance

When you are accused of this, take the time to try and draw a picture or explain it in whatever form suits you best.

#51 Beauty is due more to harmonious relationships amount the elements of a composition than to the elements themselves

"Build a car out of the most beautiful features of teh most stunning cars ever made. See if your friends will be seen in it with you."

#78 "The success of the masterpieces seems to lie not so much in their freedom from faults - indeed we tolerate the grossest errors in them all - but in the immense persuasiveness of a mind which has completely mastered its perspective."

Virginia Woolf.

#98 The Chinese symbol for crisis is comprised of two characters: one indicating 'danger', the other 'opportunity.'"

Whille it sounds good, the interpretation is false, see: pinyin.info and wikipedia

Post to Twitter Tweet This Post

Posted in design.

Productive Programming

I've had a few questions about the Productive Programming Book, here are a few of the pearls I got from it:

SLAP
all code in a method live at the same level of abstraction. Nice acronym.
Aristotles Essential and Accidental Properties
Notions of Accidental Complexity have been around for a lot longer than I thought.
Dietzlers Law - 80-10-10 (classic)
you can do 80 percent of what the customer wants in a remarkably short time. The next 10 percent is possible, but takes a lot of effort. The last 10 percent is flat out impossible because you can't get "underneath" all the tooling and frameworks. And users want 100 percent of what they want, so 4GLs gave way to general-purpose languages (Visual BASIC, Java, Delphi, and eventually C#). Java and C# in particular were designed to make C++ easier and less error prone, so the developers built-in some fairly serious restrictions in the interest of keeping average developers out of trouble. They created their own versions of the "80-10-10 Rule," only this time the stuff you couldn't do was much more subtle.

Post to Twitter Tweet This Post

Posted in Uncategorized.

link and self; rel=”canonical” and rev=”canonical”

This is based on a cross post from http://www.innoq.com/blog/st/2009/01/link_and_self.html.

Subbu and <Stefan Tilkov have been discussing URI Equivalence, linking to self and Resource Identities, so here is my view.

Subbu's last remark asks the question

>>>
On January 18, 2009 4:32 AM, Subbu Allamaraju said:
Here is a longer response that is longer than a comment <img src='http://brettdargan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />

http://www.subbu.org/blog/2009/01/uris-vs-identifiers-take-two

IMHO URI non-equivalence does not imply resource non-equivalence. And if that is really important to your application there SHOULD be ways to handle it.

I agree with Stefan on providing a canonical resource.

You can argue both ways that person and person with address book are either two representations of a person resource, or two different resources, that is the great thing about the Web.

For this case in the atom self link what about using the <b>rev tag</b> to identify the canonical resource that makes sense for your application.

Since rev also accepts space separated list of link-types you could mark it with both the type and the uri of the canonical resource.

<link href="http://www.example.org/person/abc?include=addressBook" rel="self" rev="canonical http://www.example.org/person/abc"/>

As to whether or not two different entities that returned from different URI are based on the same version of the canonical resource or not:

I would use an EntityTag that encoded some value of resource state and some value of the representation. Eg. template for xhtml representation may change without resource state and the ETag must change in order to reflect that.

To KISS.

If you had an ETag consisted of something like "resourceVersion=20,reprVersion={date}" Then your application could extract out the self links with identical rev tags and extract from the ETag the resourceVersion.

Post to Twitter Tweet This Post

Posted in RESTful, Web, design. Tagged with , , .

URI Design – Matrix Params for cross-cutting concerns

Looking at URI design, there are a lot of cross-cutting concerns across many a resource. It would be great to come up with some conventions for the most common.

These are some of the ones I've been percolating on.

You can see there are a broad range, including:
  • different views or representations of a resource, around breadth/depth of it's data and relations
  • user request based affects on a representation
  • resource version
  • application supporting mechanisms, returning fragments and forms or form fragments
  • temporality

There are a few more, but the trick is having less, right.

;version entity version that is
;_for_edit ;_for_inline_edit return html fragment
;_at_instant={utc_milliseconds} get this resource as it would be represented at this point in time
;_for_period=iso8601 format holidays during these periods/durations. die to start and end date ranges. or ;_for_interval
;_role=admin  
;_repr=code_value representation of code_value. May also need numcode_value and maybe a triple for code,short name and description
;_repr=summary|detail|depth you get the idea
;_repr=no_ambiguity return a 300 Multiple Choices, if there must be no ambiguity in the request. If the request can not fully determine the intended resource. Often in practice a convention will be followed, like the latest version of the resource. If you support multiple versions do you do what wikipedia does and offers a disambiguity page (as a standard OK response). Although disambiguity pages could cause issues in situations where you expect all particular requests of a resource to return same formatted representation ie. no ambiguity.
;additional_param=xyz #ambiguity resolution
;fragment  

See also ISO8601

Post to Twitter Tweet This Post

Posted in RESTful, Web. Tagged with , , .


Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.