MOIA goes Scala Days Lausanne

Our Scala backend teams are currently celebrating the 10th anniversary of Scala Days in Lausanne, the biggest Scala conference worldwide.

Our Scala backend teams are currently celebrating the 10th anniversary of Scala Days in Lausanne, the biggest Scala conference worldwide. Scala is a modern programming language which enables us to provide the best user experience throughout a trip. We have answered the most relevant questions with regards to how we use Scala at MOIA.

In which business areas do you use Scala?

In the most essential parts of our ridesharing service where the needs for low latency, resiliency, and complex business models come together. Our Scala-based microservices in the passenger domain ensuring a seamless booking experience, secure payments and that the customer receives real-time events such as vehicle location updates reliably. In the pooling domain, Scala is used to deciding which vehicles and stops are eligible for a trip request taking into consideration real-time fleet state, vehicle capacity and other constraints.

Why did you choose Scala as one of the main programming languages and what kind of problems does it solve for you?

The clarity and expressiveness of Scala help our developers to focus on the essence of the problems instead of dealing with language semantics, leading to rapid development. The strong type system and immutability by default approach allow building stable systems that stay maintainable even though they grow over time.

The Scala ecosystem offers lots of different libraries and abstractions to deal with the same problem. How do you select the right tool for the given use case?

With a combination of autonomy and governance. We have defined and iteratively adjust principles and tech baselines which every development team needs to fulfill. Blueprints providing orientation when implementing these tech baselines. Teams can choose the best libraries for their use case as long as the principles are followed and each team member believes in them. The Scala Community of Practice and other continuous learning formats enable knowledge sharing across our Scala teams and provide room and time for continuously innovating.

Which Scala libraries are you using in particular?

We are heavily using Akka Streams and in some systems Akka Cluster techniques such as Sharding and Singleton. Akka Streams is used end-to-end to describe the process of a business workflow, i.e. calling individual stages necessary to process an HTTP request or event. This way, we can back-pressure requests early on in case downstream stages are overloaded. Each stage is then implemented with Futures or Akka actors, depending on the need. If we need to keep the state in memory, Akka actors are used to safely access the state concurrently (single-threaded illusion).

The Typelevel stack (fs2, shapeless, cats, doobie, etc.) is currently considered to be used for new services. Important for us is that the entire team is convinced that the new library brings business value in the long run and that they feel competent to use the library in production use cases. To build up the knowledge, we try out libraries on the side and then decide together if it is worth the switch. This way, we avoid knowledge island within the team and across the Scala stack.

How does your overall infrastructure and system architecture look like?

When we started MOIA it was our primary objective to deliver decoupled services that are scalable, flexible, secure and stable enabling short lead times. Our distributed system is running fully on AWS and consists of various microservices and AWS Lambda functions. This allows focussing on solving business problems and to scale both in markets and team size. The Scala microservices are deployed with Kubernetes. Independent Self-Contained Systems allow concurrent progression of teams. For asynchronous communication across Self-Contained Systems, Kinesis and SQS are used. To interact with the mobile apps we use HTTP with protobuf, AWS IoT for pushing real-time updates and Firebase for push notifications.

 

This sounds very cool. What kind of mindset should I bring along when working in one of your Scala teams?

Due to the high autonomy of our teams, you should live and breathe DevOps and believe in automated testing, infrastructure as code, continuous deployment, monitoring, and open communication. In addition, you should be keen to receive and give constructive feedback and love to solve the challenges that arise in distributed systems with Scala and cloud-native technologies.

Can you explain in simple words why a good technology choice is important for a MOIA customer?

We want to provide the best user experience possible. This means that we need to adapt to customer feedback quickly while still providing a stable service. Using the right infrastructure and technologies allows us to achieve both goals that are actually contradictory to each other. Using innovative technologies and providing continuous learning opportunities also attracts talented developers from all over the world which is fundamental to build beloved software solutions.

 

Join us and let your code drive our cities: https://www.moia.io/en/career