10gen, the company behind the MongoDB database, recently announced the availability of the MongoDB Backup Service. This is not a traditional backup service, though. Rather than simply sending scheduled snapshots of the data over to a remote system, the backup service has an agent sitting next to the database that monitors its operation log, and streams the individual operations over to the remote backup servers. This model enables the service to offer some non-conventional features, such as restoring the state of the database at any point in the last 24h, in addition to more traditional snapshots over longer periods.
This isn’t the only interesting fact about how the system was developed, though: the backup agent is also the first software 10gen releases that is written in the Go language. Being the author of the Go driver for MongoDB means I’m of course biased towards thinking this was a good idea, so I’ve invited Daniel Gottlieb, the main 10gen engineer behind the service agent, to provide some feedback about the choice:
Programming the backup agent in Go and the mgo driver has been extremely satisfying. Between the lightweight syntax, the first-class concurrency and the well documented, idiomatic libraries such as mgo, Go has become my language of choice for writing small scripts up to large distributed applications.
It’s a wonderful feeling to start work on a project and not have to debate with the group, “Maven or Ant? JUnit or TestNG? Spring or Guice?” I don’t necessarily agree with every convention the Go language team has chosen (e.g. tabs over spaces), but I love that they’ve leveraged these conventions to create a sensible, uniform development experience with the holy trinity of tools: go build, test and fmt.
The mgo driver is a real pleasure to use. The code is of high quality, the documentation is thorough, clear and detailed, and the API is a thoughtful, natural blend of idiomatic Go and Mongo.
I’m big on writing disciplined code. It’s not always fun to carefully validate all of the input before running it through a cool algorithm, but it’s important for the maintenance cost of the application. Exceptions offer the opportunity to jump straight into coding an algorithm at the expense of a false sense of security and code maintainability. Perhaps the more I program in Go, the more I’ll realize which patterns exceptions are useful for, but for now I think the primitive style of using error values makes me a better programmer.
Those are encouraging words, Daniel. It’s great to see not only 10gen making good use of the Go language for first-class services, but contributing to that community of developers by providing its support for the development of the Go driver in multiple ways. Good chance to say thanks!