Play Framework, Akka and Scala at Gilt Groupe
Gilt recently migrated to the Typesafe Platform for their modern e-commerce system. We’ve written up a case study to capture all the details of why they moved to Play Framework, Akka, and Scala. We also wanted to get more insight into their architecture and motivations for the switch, so we sat down with their tech team for a short Q&A...
Typesafe: Tell us a little bit more about Gilt and the back-end technologies that support your services.
Gilt: Gilt started out as a Rails app backed by PostgreSQL. As the site grew, we really needed to focus quickly on scaling up the application. The approach from the beginning was to move towards a service-oriented platform, starting with the applications that carried the most load and moving through the funnel. We wrote all the new services in Java, which proved to be more than 10 times more cost-effective at scaling to the levels of traffic we were seeing.
Over time, though, our loosely-typed approach to services in Java (which in many respects mirrored our Rails approach) became difficult to scale across a rapidly growing organization. We began looking for a more type-safe approach – particularly for our internal APIs. Out of this conversation grew, in parallel, our core data model and client APIs, which we call Commons, and which is implemented in Scala but is mostly Java-compatible; and a micro-service approach built around the Commons model. Starting in late 2011, and through 2012, we experienced increasing success with the performance and usability of Scala at Gilt. In mid-2012 we began looking at Play 2 as well, particularly as we were interested in exploring WebSockets and how they might be used to enhance the ecommerce experience.
TS: How is the future of ecommerce evolving, and what role does Play, Akka and Scala have in addressing these shifts?
Gilt: The ecommerce business is extremely competitive on price, speed, and features. From a development point of view, maintaining velocity is important for keeping features flowing with minimum friction. Being able to reliably build the tooling we need to simplify our internal workflows is also important for the back office. Flash sales typically have incredible non-functional requirements. Our sale spikes tend to involve a two-orders-of-magnitude increase in traffic over the course of a few seconds – so much so, that we often refer to “requests per decisecond” instead of “requests per second” to drive home how quickly traffic can ramp up. The Typesafe Platform has scaled really well for us across our internal verticals, making it simple for us to build, for example, internal-facing workflows using the same tooling we use to build the highest-performance web pages.
By being early adopters of Play, we were able to move quickly and easily to a WebSocket architecture (via actor integration) that has led to a nice increase in conversion. We’re still evaluating Akka, but as we gain more experience with it, we see it becoming an integral tool. Akka enables asynchronous front-ends and offers a faster, more responsive, progressive web experience than what we would have been able to achieve with similar effort on other platforms. The actor model helps to break down functional units in code and maintain focus on the workflow. It also reduces friction for concurrent programming by eliminating boilerplate code and the bugs that frequently come with it.
The Typesafe Platform enables us to move faster, build on what we have done, do less overall refactoring, and – we strongly believe – attract the best people.
TS: How does Gilt use WebSockets? How does Play’s WebSocket support stand out?
Gilt: Our “Gilt Live” page was the first app that we wrote to use WebSockets. At the time, we were not fully a Scala shop yet, so we looked at a number of alternatives. Play stood out from the others by making the model easier to understand, and encouraging clean code. Ultimately, we found that our front-end teams were going to choose Play whether we wanted them to or not. Developer happiness is a big consideration at Gilt, and the simplicity and speed with which we could build high-quality things was, for us, ultimately compelling.
TS: What are the business benefits of adopting Scala?
Gilt: The promise that Scala scales along multiple axes has proven true for us. We are using Scala on our frontend, our backend, our tooling, and even in some operational automation scenarios. Having no impedance mismatch in the tooling in these varied domains leads to overall greater productivity. Scala has proven to be extremely capable and expressive, and as a result our services and applications are now smaller – with more tests, fewer bugs, and simply higher quality code.
Adopting Scala has also energized a number of developers. Learning Scala is a deep process that can take years. Although it’s easy to get up and running, for the intellectually curious there is a lot to explore.
TS: How do actors in Akka assist with Gilt’s unique site traffic patterns?
Gilt: Over the last year, we’ve really started to see teams use actors more and more, and we’re bullish that they will play a prominent place in our tech stack going forward. At the moment, our most visible use of actors involves the various Play apps we are running, which use WebSockets to provide real-time inventory updates throughout the site. On our product detail page, for example, you can find sizes and colors updates that let you know if a product is still available or sold out. On our listing pages, you can see a real-time count of how many units of a given product are left.
We are in the initial stages of building our checkout workflow to use actors to model orders in progress.
If you have any questions for the tech team at Gilt or the Typesafe team, please leave your questions in the comments section and we’ll do a follow up blog post on Gilt Tech in the coming weeks! Also, if you're in NYC on July 25th, Gilt will be discussing Play Framework at the New York Times Open Source Science Fair, so swing by their booth to learn more about how they are using the technology in production.