Book Image

Building Applications with Scala

By : Diego Pacheco
Book Image

Building Applications with Scala

By: Diego Pacheco

Overview of this book

<p>Scala is known for incorporating both object-oriented and functional programming into a concise and extremely powerful package. However, creating an app in Scala can get a little tricky because of the complexity the language has. This book will help you dive straight into app development by creating a real, reactive, and functional application. We will provide you with practical examples and instructions using a hands-on approach that will give you a firm grounding in reactive functional principles.</p> <p>The book will take you through all the fundamentals of app development within Scala as you build an application piece by piece. We’ve made sure to incorporate everything you need from setting up to building reports and scaling architecture. This book also covers the most useful tools available in the Scala ecosystem, such as Slick, Play, and Akka, and a whole lot more. It will help you unlock the secrets of building your own up-to-date Scala application while maximizing performance and scalability.</p>
Table of Contents (17 chapters)
Building Applications with Scala
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface

Scaling up microservices with an Akka cluster


Our application also uses Akka. In order to scale Akka, we will need to use an Akka cluster. The Akka cluster allows us to clusterize several Actor systems in several machines. It has special Actor routers that are cluster aware, and we can use these Actors to route requests to the whole cluster; more details can be found at http://doc.akka.io/docs/akka/2.4.9/java/cluster-usage.html#Cluster_Aware_Routers.

The Akka cluster provides membership protocol and life cycle. Basically, we can be notified by the cluster when a new member joins or when a member leaves the cluster. Given this capability, it is possible for us to code a scalable solution around these semantics. As we know when a member joins, we can deploy more nodes, and we can also drop nodes on demand.

A simple sample would be to create an Actor called frontend, and when we see this Actor, we could deploy three backend Actors across the cluster. If the frontend Actor leaves, we could undeploy...