Travels with Epicurus

Wonderful book by Daniel Klein on old age with wisdoms to tackle it and can certainly be applied to young and mid age too. Tidbits I found to cherish:

“Nothing is too late” refrain is too tempting for old-agers but look at Longfellow’s poem:

Ah, nothing is too late
Till the tired heart shall cease to palpitate.
Cato learned Greek at eighty, Sophocles
wrote his grand Oedipus, and Simonides
Bore off the prize of verse from his compeers,
when each had numbered more than fourscore years
And Theophrastus, at fourscore and ten
Had began his “Characters of Men.”

Epicurus was not a sensualist and he was not looking for dazzling sensory excitement. He’d always say bring on those plate of boiled lentils! He had Zen like attitude about his senses: if fully engaged in tasting the lentils, he would experience all the subtle delights of their flavor, delights that rival those of more extravagant spiced fare.

Epicurus was not afraid of death. He famously said, “Death is nothing to us, since when we are , death has not come, and when death has come we are not. The absence of life is not evil; death is no more alarming than the nothingness before birth.

On boredom in old age:

The most hyperactive of us are precisely those who have the lowest boredom thresholds. We scurry activity after activity as we cannot face tackling tine that is ‘empty’. The predestined disappointment built into desperately yearned-for newness has found its expression in many ironic aphorisms – like Oscar Wild’s: “In this world there are only two tragedies. One is not getting what you want and the other i s getting it. The last is much the worst.”

How do you explain infinite regression:

Andreas: What holds the world up?
Orestes: Atlas, of course
Andreas: But what holds up Atlas?
Orestes: He stands on the back of a turtle
Andreas: But what does the turtle stand on?
Orestes: On another turtle’s back
Andreas: But what does that turtle stand on?
Orestes; MY dear Andreas, it’s turtles all the way down!

Epicurus on Sex:
Sex may go out of hand, to skitter outside the all important comfort zone.  Marriage and procreation, yes these provide lasting satisfactions. but sex – and purely sexual love – inevitably leads to more unhappiness that its fleeting pleasures are worth. Sex exposes unnecessary and insatiable needs that bare vulnerabilities and promote anxieties. He mapped the sequence in which sex causes misery: it starts with lust, moves on to ardor, peaks with consummations, and then goes directly to jealousy or boredom or both. When age catches up with our libido: There are discrete stages of life, each with its own qualities, and that fudging these stages is to fudge the inherent value of each of them. It feels more authentic to me to recognize that human desires and capabilities change from one period of life to the next, and that to deny that they do is to miss out on what is most fulfilling about each stage. Wanting to want something that he doesn’t really want that much, and in his old age, no less, just seems counterfeit, untrue to himself

The best antidote for anger is delay – Seneca



Azure Table Storage as Document DB – Observations

Azure Table Storage (ATS) is definitively a great product but with its own limitations. I was considering ATS to be the backend for a B2C receipt document db which need to scale up to millions of users whose receipts generated will be at 1 billion (at an 2 to 3 per day amounting to average 1000 receipts per year – good case and may be 12K receipts per year worst case). The data requirement will be 3TB/yr and growing with more user count. I was very optimistic to turn ATS into the best possible backend for this solution but slowly realized it may not fare to my realistic expectations. I’ll go through one by one that forced me otherwise:

ATS and Speed:

My initial design was to house every year’s worth of receipts in a separate partition with row key being unique and each customer having their own tables to ensure proper data distribution. I filled a partition with meta data and receipts data (about 26450 records) and did some query operations using LinqPad (its azure driver helps a lot here) and found response to average 7 to 9 seconds to query receipts on partition key and other meta data fields. As documented it was slow as it doesn’t involve partition key and row key. Well, when I repeated the above operation with 1000 rows, also the result was same and response varied but stuck to few seconds, not good for a B2C website response timing perspective. The response exacerbates when continuation tokens are involved. Moreover transaction cost is pain as well. Also introducing a web tier to serve these receipts will be additional overhead and performance suffers even more. Other interesting aspect is caching by ATS for a given partition, 1st time query is very expensive but suspect subsequent queries may be fetched from cache and response seems quicker but still unreliable. Even as an adjunct to serve individual objects may not be fast but lazy loading is a possibility where the users can see the first object loaded followed by the rest of the objects, There’s one more impediment as discussed in the next section to serve a B2C customer meaningfully from a site.

I was contemplating to scale for more accounts per subscription to manage data size scalability versus data throughput supported . Specs are here

  • Capacity – Up to 100 TBs
  • Transactions – Up to 5,000 entities/messages/blobs per second
  • Subscription gets 5 storage accounts
  • One storage account = infinite tables
  • Each table = infinite rows

SQL Batch throughput analyzer can give some idea on batch inserts and reads but again ATS is good for lazy object serving and data storage around the limited table design orientation with NoSQL percept. Lokad gives a nice syntactic sugar to manage transient faults and rich data type to manage objects in ATS and was about to customize it further to my requirements but abandoned it midway.

Query Flexibility:

I was thinking I could do OrderBy but is not supported by ATS and believed that my inline List object (in web tier) filled with objects/records from ATS on a conditional query may help, but the response being not on par, I abandoned this path.  I also looked at this nifty trick to somehow select latest receipts deposited into ATS partition of a customer (my planned design was: partition key = year of receipt date and row key = date time tick as generated from the article link) but given receipts from different merchants may have same receipt date doesn’t allow this to be used.

Some good links to understand the ATS querying:

Everything you need to know on ATS
Book on ATS
Another Slide

ATS Data Exposure:

ATS data cannot be extracted from client side query as it neither supports JSON and JSONP if you’re serving the JavaScript from a different domain. Your site may be and ATS may reside at http://<account&gt;<TableName>.  There’s a good alternative but not sure this is the best way to go. The other way is to create a CNAME to mask the Azure URI to your site URL with a subdirectory to expose ATS.

I was planning to use masonry.js with data fed from a tabletop.js like data extraction (tabletop.js provides a way to extract records from Google docs/excel sheets). As said above ATS lacks JSON/JSONP and hence it is out. Now I’m moving towards a real document database, possibly Raven DB or open source stuff that has no transaction cost, easier object exposure and very fast access.