In an ideal world everything would just work fine all the time. However, the real world is rarely like that which means we need to handle failures. Different programming languages have different approaches to modelling failure, but even with Scala there are numerous differerent ways of doing so. This talk takes a look at the various types of errors and exceptions you’ll need to deal with and suggests ways to model them.
The twelve-factor methodology is a pretty solid approach to deploying applications that can run locally and in multiple cloud environments, as well as being able to scale out on demand. We’ve used this approach at Deliveroo since time immemorial (about three years ago), at least in part because with Rails it Just WorksTM. With our more recent use of Scala and the ubiquitous Typesafe Config library it’s actually rather harder. After many attempts I finally found an approach I’m happy with.
Akka HTTP’s client uses connection pooling, either implicitly when you use the
singleRequest method, or explicitly when using
superPool. The number of requests that can be made in parallel and how backpressure works is governed by the
max-open-requests settings, but these have some slightly surprising behaviour which isn’t quite what the documentation suggests. This post demonstrates how these APIs work and discusses when to use each of them.
When I interviewed for Deliveroo a little over three years ago it was a tiny company so the ‘process’ was just a series of chats with a senior engineer, the CTO, and the CEO. All held in coffee shops because the single-room office had no free space. This approach is typical for early stage startups, and it actually seems to work reasonably well because we managed to hire some great engineers, many of whom still work at Deliveroo. But it’s not really a scalable way to grow a team.
With functions that can fail, people tend to think there are two possible options, success or failure. This is what’s modelled by Scala’s
Future[A] types, as well as plain old
catch. However things aren’t quite as simple as they might first appear. Let’s go down the rabbit hole.