Yoco reasons to use Hydra: 7x faster Scala compilation, fewer bugs in production, and developers happiness!

Hydra has had a tremendous impact on our organization: our Scala project compiles over 7x faster, the code we ship is safer, and our developers are happier!

-Andrew Snowden, VP of Engineering at Yoco

Yoco’s mission is to enable small businesses accept credit card payments in South Africa. In fact, while gaining access to credit cards is relatively simple for consumers, businesses face a much steeper barrier in getting bank’s approval. And even when they do get approved, it can still take several weeks before they can process credit card payments. In contrast, by teaming up with Yoco any merchant can accept credit cards on the very next day!

Fast execution is not the only competitive advantage, the Yoco’s platform plays a decisive role in keeping them ahead of their competition. As of 2019 Yoco supports more than 45’000 businesses with a total of over 30 million yearly transactions.

Scala, Play, and Slick – the heart of Yoco’s platform

Scala and the Play Framework power all backend services, together with Slick to interface with PostgreSQL. On the frontend, React.native is used for the mobile apps, while React and NodeJS are the technologies of choice for the web app. To synchronize data between the backend and the mobile apps Google Firebase is leveraged. The platform is deployed on Heroku.

The Yoco backend team has 25 Scala engineers following a pretty typical git feature-branch workflow. The codebase is hosted on Gitlab, while Gitlab CI together with Amazon EC2 auto scaling capabilities are used for validating all commits and keeping the feedback loop to a minimum.

From Monolith to Microservices?

While the original platform’s architecture is essentially a monolith, it’s slowly transitioning toward a microservices architecture. The driving factors behind the re-architecture effort are:

  1. the need of higher services’ isolation, and
  2. reducing compilation time.

Of the two, the second was the most pressing problem, as it used to take over 20 minutes to run a full compile (including tests) of the Yoco project on a developer machine using the vanilla Scala compiler. This was massively impacting developer productivity, and it was also having the unfortunate consequence of pushing the team to write fewer tests.

Despite the urgency, an immediate transition to a full microservices architecture would have led to several man-months effort, forcing the delay of the delivery of critical features needed by the business. This was a hairy situation!

Reducing compilation time through modularization

The first attempt at reducing compilation time was to extract portions of the code into external libraries. While that reduced somewhat the platform project compilation time, new problems emerged:

  1. It was extremely inconvenient having to release a new version of the library every time a change was made.
  2. Additional time had to be spent in integrating and testing.

This refactoring was costly in the first place, and highly disturbing the day to day development. Therefore, they kept looking for a better solution.

Faster, safer, and happier

In early 2018 Yoco VP of Engineering Andrew Snowden found out about the Triplequote Hydra parallel Scala compiler, and he was quickly convinced. Compilation time dropped from 20 minutes to less than 3 minutes on a quad-core laptop: Hydra compiled the Yoco platform project 7 times faster than the vanilla Scala compiler!

Andrew said that Hydra has had a tremendous impact on Yoco organization:

  • Reduced context-switch time: Hydra makes a huge difference when switching branch and a full recompile is needed. Prior to Hydra, compilation after switching between branches would take 10 minutes.

  • Application correctness: The testing has changed a lot as the compilation of tests was a huge struggle before Hydra. But after switching to Hydra we started writing a lot more tests. And, as a consequence of that, Hydra made our production code safer.

  • Developer happiness: There was a lot of frustration prior to Hydra. Hydra really has relieved the tension on the team and made it possible to focus on the task-at-hand as the change-compile-test development cycle is really fast now.