In today’s cutthroat digital economy, companies are continually looking for a competitive edge that leads them to increased revenue. Appropriately targeting advertisements based on empirical data derived from customer behavior is one such edge, however up until recently it was only possible to obtain this information via a users interaction in a solitary web browser. Tapad’s innovative product offering transcends the physical barriers between devices and enables advertisers to view a complete picture of user activities in real-time across all devices. Tapad turned to the Lightbend Platform to serve as the basis of this truly remarkable system, capable of handling massive load with huge concurrency requirements, along with SLA’s measured in milliseconds.
Tapad is the undisputed leader in cross-screen advertising technology. The company’s groundbreaking technologies address the new and ever-evolving reality of media consumption on smartphones, tablets and home computers. Through Tapad, advertisers are able to get a unified view of consumers across all screens. Tapad has built the most robust, real-time cross-platform audience buying technology available.
Dag Liodden, Co-Founder and CTO at Tapad faced an interesting challenge: how to deliver a robust system that enables marketers and advertisers to consistently reach the same person across multiple devices such as iPads, iPhones, computers, gaming consoles, connected TV’s, etc? Many companies talk about single device/browser advertising, but reaching across multiple screens and correlating the behavior in real time was a monumental task.
Finding the right solution
Since Dag had worked on the JVM for 16 years, he knew the platform very well, and even with the drawbacks of Garbage Collection he was certain that the JVM was an excellent base upon which to build a high-performance, low-latency system. Bruce Tate’s book, “Beyond Java” (2005) introduced the concept of polyglot programming and opened peoples’ eyes to using different languages on the JVM; Tate’s book inspired Dag to investigate alternative languages to Java as part of the technology stack evaluation process.
While Dag liked dynamic languages, he saw the value in statically-typed languages as an interesting way of addressing the shortcomings of Java. Furthermore, Dag already had some interest in Scala and had been dabbling with it for a couple of years. Ultimately, there were three main technical reasons that drove the reasoning behind choosing Scala and the Lightbend Platform:
- Statically typed tooling.
- It ran on a standard JVM container.
- The Actor model is a very good fit for solving some problems in a high frequency, high throughput system with lots of stateful decisions and heavy concurrent access to mutable state.
The non-technical reasons for choosing a platform are often as important – or more so – than the technical ones. A huge driver during Tapad’s early days was the desire to build a strong team. There are many ways to get talent, however the best way is to offer developers something new to learn and push the envelope. Ultimately, Tapad wanted an edge with candidates that not many other companies had; ten years ago Python was that catalyst, but in 2011, Scala was becoming mainstream and was a language that Dag felt, every developer worth their salt wanted to use.
Building the Solution
Tapad’s core backend system had to scale well. It’s a low-latency, high-throughput and needed to scale across many servers. Consequently, speed was very important – every request had to be responded to within 50ms (including network traffic leaves 5-10ms actual processing time). By crunching 150 billion data points from cookies, cellphone IDs, Wi-Fi connections, website registrations, browsing history and other inputs, Tapad looks for the commonalities that link one device with another.
High developer productivity was a critical aspect too, so the availability of Lightbend’s Akka toolkit was very important. Akka is an asynchronous event-driven middleware implemented in Scala, for building high performance and reliable distributed applications. Akka decouples business logic from the traditional lowlevel mechanisms such as threads, locks and non-blocking I/O thereby allowing developers to focus exclusively on value-added tasks rather than getting involved in low-level system plumbing.
Interestingly, Tapad utilizes a standard servlet container – Jetty – for their runtime. There were not many options in the scalable web framework arena a few years back, and Tapad needed something that would help them ease into the use of Scala, keeping things familiar to the old model they were used to. They started with Spring Framework, using the standard ways of doing dependency injection with Scala. About a year and a half ago Tapad moved towards Scala’s idiomatic ways of structuring applications. Tapad’s applications are very object-oriented in design – a tenet that Martin Odersky, the creator of Scala – believes is a good practice for modularizing applications. Applications are in modules that are primarily objectoriented, but use functional aspects underneath.
One of Scala’s most important features is that of Java interoperability - everything has to work - this has been painless.Dag LioddenCo-Founder and CTO at Tapad
Tapad utilizes the Akka framework heavily for all application aspects where extreme concurrency is required; this is particularly useful for bidding decisions – in Tapad’s case, bidding decisions occur when the application needs to determine how much to pay for individual advertisements. Tapad layers its powerful decision engine on top of the billions of impressions that they access on a monthly basis. Their bidding algorithms draw both on predictive learning and historic performance to calculate in real time the likelihood of an impression to meet their client’s targeting parameters and achieve their ROI goals.
Other notable frameworks/components in use by Tapad consist of:
- Apache Kafka Queuing System
- Aerospike Key Value Store Cluster
- Data Warehousing solutions – Vertica and Hadoop
At this point in the evolution of Tapad’s infrastructure, Spring Framework is no longer used and all “original code” is written in Scala. Specific Scala frameworks in use include:
- HTTP dispatch library
- Twitter Finagle
Lightbend’s Play Web Framework is being used exclusively for the front-end of Tapad’s application.
Tapad started building their application with two engineers in 2010; the Minimum Viable Product (MVP) was running live in just a few months. Today, Tapad has sixteen engineers on staff, and is continuing to hire aggressively (and carefully!). In the beginning, everyone was a generalist, working wherever they were needed; today, there are pure front-end and back-end teams consisting of Play, data and infrastructure engineers. On occasion, Tapad finds it necessary to drop into Java to accomplish a task, but that is rare and they have sworn never to go back! Overall, Scala been very, very nice for for what Tapad does.
Our application is not a typical CRUD database application; a lot of what we do is algorithmic, so things that would ordinarily take tons of code in Java are easy to express concisely in Scala. We’ve come to realize that picking up a framework and understanding the code is actually easier in Scala than Java. Scala focuses on logic and what’s going on, and is less about the structure and where to find things. Maintainability is much better!Dag LioddenCo-Founder and CTO at Tapad
Dag has noted that in the past, binary compatibility has been a challenge on Scala, but he’s looking forward to seeing how the newest release improves this. Tapad is in the process of moving to Scala 2.10 and Play 2.1 over the coming months, and they are also adopting the Slick Data Access Framework in this next iteration.
Inspired by this story? Contact us to learn more about what Lightbend can do for your organization.
Share This Case Study
Lightbend is the proud provider of the world's leading Reactive application development platform. We are a passionate crew of technology pioneers committed to building amazing software. We build and maintain the Play web framework, the Akka message driven runtime, and the Scala programming language. Our mission is to help developers build high-performance applications that are responsive resilient, elastic and message driven.