Friday, 31 October 2008

How To Cache Highly Dynamic Data in Rails with Memcache – Part 1

There are a number of ways increase Ruby on Rails performance through caching. Caching works because things don’t change….or don’t change frequently.

In Cullect, almost everything is dynamic, even Cullect’s HTML presentation format has 3 different states depending on access privileges and there are 8 other presentation formats available.

The standard page, action, and fragment caching make less sense when the ‘heaviest’ data are also the most dynamic – the feed items.

For the feed items, I’m using a building a custom memcached name-value-pair holding 10 attributes describing the request as the key name and the items themselves as the key value.

From the ‘show’ action in my controller:

key = "
#{item_count}:
#{attribute_1}:
#{attribute_2}:
#{attribute_3}:
#{attribute_4}:
#{etc...}"

Notice the first attribute in the key is the total number of items within a specific Cullect Reading List – which will change when a feed updates or an item is hidden – automatically expiring stale caches.

Then, I check the cache for the key and pull the items from the cache if it exists.

if Cache.get(key)
@allitems = Cache.get(key)

If there’s no key in the cache, I do the query and put the retrieved items into the cache.

else
@allitems = get_items(attribute_1, attribute_2, attribute_3, attribute_4, etc)
Cache.put key, @allitems
end

While this speeds up subsequent requests, there’s still the question of speeding up the initial request. I’ll save that for part 2.

Tuesday, 21 October 2008

Information as Milk or Wine?

I’ve been thinking about information – ‘news’ if you will – quite a bit lately – in the context of other things we ‘consume’ – beverages.

 

Milk   Wine
Kids drink it Adults drink it
Paired with cookies   Paired with dinner
Expires/Smells funny   “Gets better with age”
Homogenized   Vintage
Price varies little   Price varies greatly
Un-vegan   Un-vegan

Obviously, the ‘wine’ side is more attractive (at least to mildly-lactose-intolerant me). Cullect and its ‘Important Rank‘ is built on the ‘wine’ side.

Note: I consider this a half-formed post.
To Do: figure out if/how this ties into Matt’s Newless.org project.

Sunday, 19 October 2008

Phone Home, Redux

In the past two weeks, Jen and I have both replaced our mobile phones. A process too much akin to purchasing a new car or house for my comfort.

Just a few years ago, phones were still tied to a geographic location. Home, work, phone booth on the corner. Amusing to think that ‘the place where telephone conversations occur’ was tied to an actual geographic location.

Today, mobile phones and increased coverage areas have all but removed IRL geography location from cyberspace.

Without a fixed geography, virtual.

This is my second year with T-Mobile’s HotSpot @Home service. With this service, my conversations are delivered over VOIP (when I’m within a wifi network) and the duration of these VOIP conversations aren’t counted against my ‘regular’ minutes.

For a productive work-related phone conversation, I need internet access anyway, so this works perfect. Additionally, if I’m not within a wifi network, I’m probably driving or otherwise not able to talk.

But what about this next time I need to purchase a mobile phone service plan? Sometime in 2010.

I see the continued proliferation of fast, stable, open, wifi making it possible to drop traditional mobile phones in the same way more than 13% of Americans have already dropped their landline phones.

I predict the challenge of polling the 2012 Presidential election will be that 13% of Americans are “soft” phone-only.

Again returning us to a time where a specific, connected place is required for voice conversations.

Maybe, I’ll still keep a ‘regular’ mobile phone though, you know, for emergencies.

Thursday, 16 October 2008

Un-Plumb

We’ve been introduced to a number of crazy characters this election season; Joe Sixpack, Hockey Mom, Senator Government, and Joe the Plumber.

Signs of Jumping the Shark #18:
“Introduction of new characters to revive interest, particularly young, cute children who are clearly intended to replace regulars who once were but have grown up.”

“In the nightmarish near-future, galloping bureaucracy and increasing social decay have produced a society where man can be condemned to death simply for working as a plumber without a license. – Adam-Troy Castro

Sunday, 12 October 2008

Saturday, 11 October 2008

First Crack 111. Patricia Cumbie’s ‘Where People Like Us Live’

From the unpublished First Crack archives, I bring you a conversation I recorded in July 2007 with Minneapolis novelist, Patricia Crumbie on her then – yet to be published – young adult novel, Where People Like Us Live.

As you can tell from the links above, her book is now available. 🙂

In our conversation, we cover the book itself – a pretty tough topic that makes me uncomfortable, and how a course at the Loft Literary Center helped her change and polish the book to help it find a publisher.

[9 min].

Sunday, 5 October 2008

Re-grarian

In March 2007 (18 months ago), I wrote the following 2 sentences – thinking there might be an interesting short story in behind them. A kind of eco-post-apocalyptic-new-world-esque thing. The contemporary version of re-visiting the grandparents’ abandon, run-down farm in Iowa.

“Future world where ex-urbs are re-claimed by the government and turned back into farmland to feed American citizens and supply the nation’s energy. The story’s from the perspective of someone watching their parents McMansion, on a cul-de-sac, being demo’d to make room for a soy bean field.”

That initial scene stuck with me, longing to find a reason for these changes to be possible and necessary.

ELSEWHERE:

“The government looking at expanding a pioneering scheme in Flint, one of the poorest US cities, which involves razing entire districts and returning the land to nature.” – By Tom Leonard in Flint, Michigan , Telegraph UK

Mass foreclosure with the federal government picking up the tab seems like a good fit.

13.986

Driving back from WI this weekend, the car had alerted us a number of times we were running low on fuel.

We didn’t stop.

Until we reached the station closest to home (albeit one a few cents higher than the one we passed a few minutes earlier).

The car has a 14 gallon tank. 14 hundredths of a gallon remained.

“I told you we’d get home, I didn’t say it’d be pretty.”

I think some variation of this story has been told a thousand times this past week and will be told a thousand times more over the next 6 months.

Thursday, 2 October 2008

Charging for the Silver Lining

“Skydeck is now focusing on building features that it can charge for, instead of free services that attract users but not revenue.” – Brad Stone, New York Times

Thank [your-preferred-deity-here].

You know I have a pet peeve with ‘businesses’ where the metric of success doesn’t start with a $. Perhaps Web 2.0 will end the same way as the ‘first version’ – a huge shake-out wiping places with funny names off the web because they simply weren’t sustainable.

Though, I believe now is different for 1 major reason – $$$. Or more precisely – $. The amount of money, time, energy, effort to maintain a modestly successful (or even not at all successful) project is small. Miniscule. Be-your-own-VC-small.

Add a little ad-revenue atop (not my preferred method, but it works for others I know) that and expenses are covered. Actually transform ‘users’ into customers – priceless. And well positioned for sunnier times. Fun-damentals.