Wednesday, August 31, 2016

Scheduled Heroku Dyno restarts

Heroku Dynos get restarted once a day.
The cycling happens once every 24 hours (plus up to 216 random minutes, to prevent every dyno for an application from restarting at the same time). Manual restarts (heroku ps:restart) and releases (deploys or changing config vars) will reset this 24 hour period.
This is fine if you are running multiple dynos. But if you were running an app you didn't want to cycle during the day but only had one dyno (I know, I know, don't ask...) there's a quick hack you can use to instead control the time of restart so that it's done during off hours (3am or whatever works for you app's usage patterns).

You can use the Heroku API to perform a restart like below using a simple curl call. If you schedule that curl call for once-daily execution using the Heroku Scheduler add-on then you can have a reliable restart of of your app and a 24 hour runway of no unexpected cycling.

Here's the details:

# install the oauth plugin
$ heroku plugins:install heroku-cli-oauth

# create a new authorization
$ heroku authorizations:create -d "Platform API example token"
Creating OAuth Authorization... done
Client:      <none>
ID:          830d64b9-fd52-4d95-<redacted>
Description: Platform API example token
Scope:       global
Token:       1d82fc23-<redacted>

# use the new authorization token from above to interact with the API, e.g.
$ curl https://api.heroku.com/apps/ -H "Accept: application/vnd.heroku+json; version=3" -H "Authorization: Bearer 1d82fc23-<redacted>"

# so to restart dynos for an app
$ curl -X DELETE https://api.heroku.com/apps/kountdown/dynos -H "Content-Type:application/json" -H "Accept: application/vnd.heroku+json; version=3" -H "Authorization: Bearer 1d82fc23-<redacted>"

So just stick that curl command into the Heroku Scheduler for the time you want and Bob's your uncle.

More on the Heroku API can be found here.

It all pays the same (or does it?)

[I originally posted this on LinkedIn, but reposting here to have a copy on my personal blog.]

Several jobs and quite a few years ago, I was venting about some work related frustration to a friend. Despite being someone who, like me, cared a great deal about doing the right things and doing them well, he had always been more sanguine than me in the face of perceived corporate wrongheadedness.

“It all pays the same,” he said. “If you’ve told them why you think it’s the wrong thing to do and they still insist then you might as well reconcile yourself to it.” It was good advice, even if it was hard to follow.

Over the years I’ve relayed this “it all pays the same” idea to many people who’ve expressed frustration at some of the things they’ve been asked to do at work. It’s a useful little trick, just like the 10-10-10 rule for decision making. It usually gets a wry smile even if it doesn’t really fix the situation that has them all wound up.

Recently though, I’ve developed an extended interpretation. It remains true that you are going to get paid the same whether you’re working on something you believe is going to save the world or something that strikes you as an egregious waste of human talent.

The difference between the two extremes though is the price you pay psychologically to reconcile yourself to working on something your heart isn’t in. I’d say working on something you don't genuinely care about is like paying a tax — a "meaninglessness tax” if you will.

Over the years I’ve written software that’s done many different things. Here’s just a few examples of things the software I’ve worked on has done:


  • organized emergency healthcare for people on vacation
  • managed order processing for discounted menswear
  • helped conduct clinical trials for promising new cancer drugs
  • sold e-books with titles like “6-pack abs in 6 weeks!”
  • facilitated the placement of billions of ads in browsers

You probably don’t need any help picking out the ones with a higher meaninglessness tax.

Job satisfaction requires more than working on something meaningful of course. It needs to be intellectually interesting, to offer opportunities for learning and growth, appropriate amounts of autonomy, flexibility and work/life balance. It needs great colleagues and fair pay; it needs a clear vision, good leadership and the ability to get work done without bureaucracy stifling your efforts. It might even need perks like free food and free beer on a Friday afternoon. But all those things aside, what it really needs most, I think, is a sense of meaningfulness.

----

Have you ever looked in your rear view mirror only to see the vehicle behind closing the gap at an alarming pace? Worse still, the driver is oblivious to the situation, focusing solely on their phone? For several years now, distracted driving has been a worse problem than drunk driving.

At my current job with Katasi I am helping bring to market a real solution to this problem. My meaninglessness tax rate is literally 0%. And so while previous work may have paid the same, I feel much better off now that I again have the chance to work on something so necessary and meaningful.

At Katasi we plan to be hiring soon. If you’d like to work with some great people, on a really meaningful product please get in touch and I can tell you more. Or take a look at http://katasi.com/ or this piece featuring us on CNN.

Monday, January 11, 2016

Complex Systems

Borrowed from the excellent book, The Personal MBA

Gall’s Law
A complex system that works is invariably found to have evolved from a simple system that worked. The inverse proposition also appears to be true: a complex system designed from scratch never works and cannot be made to work You have to start over, beginning with a simple system.
-- John Gall, Systems Theorist

Complex systems are full of variables and interdependencies that must be arranged just right in order to function. Complex systems designed from scratch will never work in the real world, since they haven’t been subject to environmental selection forces while being designed. Uncertainty ensures that you will never be able to anticipate all of these interdependencies and variables in advance, so a complex system built from scratch will continually fail in all sorts of unexpected ways.