Stupid Java Stuff: static initializers and singletons

So, to get it out of the way: there is a fairly large segment of the Java community whose reaction to a Java-style singleton object is to hold their nose and go fleeing in the opposite direction, pausing only to git blame to know who to come back for and settle accounts with later. I know this because we all have Singleton Haters Club cards and the meeting is at the corner bar every Tuesday evening. But this post is largely in spite of that.

The topic of singleton initialization came up today. There are a lot of bad ways to initialize a singleton and I got to see a couple of them up close and personal today; that there are ostensibly principal-level Java developers who haven’t internalized Effective Java is a surprise but nobody’s perfect. Anyway, without further ado, lemme give you the wrongest (vaguely working) way to do it that I can think of.

read more

Docker Web Proxy with SSL support

So Mesos is pretty cool, but it isn’t a universal solution. Not much reason to run it as a singleton cluster, for example, so this blog is running on a Linode running all its apps in Docker containers. This is new to me, but the upside is that it’s new to everybody else too—Docker’s still pretty new and there’s a lot of green field to play with in the containerization space. While there’s that sense of openness there’s also very little to suggest what the Right Course Of Action really is. Sometimes you gotta get inventive

Speaking of inventivity, I found myself needing a way to route HTTP requests to Docker containers based on vhosts. This isn’t a new problem to have, and Jason Wilder has a neat proxy container written in Go. I needed something that could handle HTTPS as well, though. I tried extending that container to do what I wanted, but I learned two things along the way.

  • Go’s templating options are Not Ready For Prime Time. Compared to ERB, it’s straight-up miserable.
  • The list of things I would rather do than use Go is not small and includes scenarios that involve nailing pieces of myself to other pieces of myself.

Enter docker-web-proxy, which I put together while I was on vacation in Maine this week. It’s a simple Ruby-based app that polls Docker for connections and splats out the appropriate nginx config before SIGHUP’ing the service; arguments are passed via the env vars given to the containers that need to be made visible. It supports HTTP, HTTPS, or HTTPS with HTTP forwarding, and optionally supports forwarding to if that there’s your thing.

After doing some nontrivial work with Docker, I’ve come around to the opinion that Docker would really benefit from a way to tag containers dynamically at runtime—think AWS—without bringing in something like etcd or Consul (my own personal favorite in this space, HashiCorp is cool people). I get the argument for separation of concerns, but, ehh.

So, part one of this little getting-acquainted with Mesos left me with one (1) Mesos server, running apps in an app-ish sort of way via the Marathon framework. Which is cool. But there’s a lot of places to go from here.

I could install additional frameworks onto the box, if I wanted–I could bolt in Chronos to give me a cron replacement or I could wire up Spark to map and reduce things on HDFS. But those aren’t really interesting to me, not least because I don’t have any jobs that have a burning need to run at 3AM, nor do I have a few terabytes of interesting data lying around to gnaw on. So instead I’m going to stick with Mesos and see what I can do about expanding my little cluster past a singleton server.
read more

A Virtual Mesos Cluster with Vagrant and Chef

Part 2 is here.

So, blog reboot, like, thirty-four. I’m bad at blogs. But this time, I come bearing neat stuff to talk about, so maybe this’ll stick.

Anyway, since starting at Localytics, I’ve found myself thrown into a bunch of new-ish stuff. My prior ops experience was much more “developer moonlighting as a sysadmin”, rather than buzzword-compliant DevOps Ninja Powers. At Localytics I’ve been leveling those up pretty quick, though, and there’s some fun stuff I’d like to talk about a little. But we need to figure out what we want to make public first, and it’ll probably end up on the company blog before it ends up here, so I’m going to natter on a bit about something I’m doing in my spare time: setting up a Mesos cluster and populating it with apps for a side project or two.
read more