SlideShare a Scribd company logo
1 of 43
Download to read offline
Scala 
{Culture}
Who Am I 
• Now: Dynalyst 
• Lang: Korean(30+ years) 
Japanese(8+ years) 
JAVA(8.2+ years) 
Scala(a year) 
• AdTech: AMoAd DSP 
CAA Reward
What Dynalyst 
• Dynamic Retargeting + 
Analyst 
• ユーザーの趣味嗜好に適した広告配 
信を行う国内初のスマートフォンに 
特化したダイナミックリターゲティ 
ング広告
Scala USAGE
Today’s Talk 
•How to build Spray 
•How to build Akka 
•How to Monitor them
continuous importing D 
mark 
ad 
bid 
imp 
click 
cv 
redshift 
request logging importing stored 
tracking
continuous reporting D 
redshift 
date imp click cv 
2014/09 10,000 500 10 
2014/08 15,000 700 25 
reporting & 
stored summaring bidding optimization
Benchmark
What is Spray? 
http://spray.io
What is Spray? 
spray is an open-source toolkit for 
building REST/HTTP-based 
integration layers on top of Scala 
and Akka. Being asynchronous, 
actor-based, fast, lightweight, 
modular and testable it's a great 
way to connect your Scala 
applications to the world.
Concurrency
Future[T] 
implicit val ec: ExecutionContext 
val f = Future { “hello world” } 
// Future[String]
Future[T] 
implicit val ec: ExecutionContext 
for { 
greeting ← Future(“hello world”) 
name ← Future(“Han”) 
} yield s”$greeting, $name” 
// Future[String]
FutureDirectives 
• spray-routing directives 
• non-blocking actor thread
FutureDirectives 
def onComplete[T] 
(future: ⇒ Future[T]) 
(implicit ec: ExecutionContext) 
:Directive1[Try[T]]
FutureDirectives 
implicit val ec: ExecutionContext 
def respondWithBidding = { 
onComplete(bidding) { 
case Success(bid: Bid) ⇒ … 
case Success(noBid: NoBid) ⇒ … 
case Failure(e) ⇒ … 
} 
}
Type of bidding 
def bidding:Future[A<:BidResponse]
Implementation 
def bidding:Future[A<:BidResponse] 
! 
• simple but bad implementation 
Future { 
// All bidding computations :( 
}
Application Layers 
Spray Router 
Handle raw level http request & response 
Bidding Business Logic 
External Resources" 
Fetch bidding candidates from data stores
Application Layers 
Global Dispatcher 
Spray Router 
Handle raw level http request & response 
Bidding Business Logic 
External Resources" 
Fetch bidding candidates from data stores
Application Layers 
Spray Router 
Handle raw level http request & response 
Bidding Business Logic 
External Resources" 
Router Dispatcher 
Service Dispatcher 
Fetch bidding candidates from data stores 
Repository Dispatcher
Implementation 
trait Router { 
implicit val ec = RouterDispatcher 
def handle: Future[BidResponse] 
} 
trait Service { 
implicit val ec = ServiceDispatcher 
def bidding: Future[Bidder] 
} 
trait Repository { 
implicit val ec = RepositoryDispatcher 
def candidates: Future[List[Candidate]] 
}
How to test those 
Future[T] things 
• Specs2 - Matcher[Future[T]] 
bidding must beEqual(expected).await 
bidding must beEqual(expected).await 
( 
retries = 2, 
timeout = 100.millis 
)
Abstract Future 
http://logji.blogspot.jp/2014/02/ 
the-abstract-future.html
Abstract Future 
trait Router[M[_]] { 
implicit val M: Monad[M] 
def handle: M[BidResponse] 
} 
trait Service[M[_]] { 
implicit val M: Monad[M] 
def bidding: M[Bidder] = M.point(bidder) 
def bidder = … 
} 
trait Repository[M[_]] { 
implicit val M: Monad[M] 
def candidates: M[List[Candidate]] 
}
Type class & 
Implicit 
object Service { 
implicit def fs = new Service[Future] { 
implicit val ec = ServiceDispatcher 
val M = Monad[Future] 
} 
implicit def ids = new Service[Id] { 
val M = Monad[Id] 
} 
} // type Id[+A] = A
Test Again 
val s = Service.ids 
s.bidding must beEqual(expected)
M[_] for Monad 
• Monad is a structure that 
represents computations defined 
as sequences of steps 
• Don’t dive into “Monad” here!
What about Akka? 
http://akka.io
continuous importing D 
redshift 
mark 
ad 
bid 
imp 
click 
cv 
request logging importing stored 
tracking
continuous reporting D 
redshift 
date imp click cv 
2014/09 10,000 500 10 
2014/08 15,000 700 25 
reporting & 
stored summaring bidding optimization
Master/Worker 
http://letitcrash.com/post/ 
29044669086/balancing-workload-across- 
nodes-with-akka-2
Overview
Overview
How to Monitor Akka 
• Typesafe Console 
http://resources.typesafe.com/docs/ 
console/manual/overview.html 
• Kamon 
http://kamon.io/
Typesafe console 
• Great user interface 
• Support by Typesafe 
• Expensive
Kamon 
• Open Source - Free 
• Metrics: Akka, Spray, Play 
(over 50 categories) 
• StatsD, New Relic, Datadog 
• Migration could be hard
Kamon meets Zabbix
Running Thread Count
Summary 
• Future Directive on Spray 
• Abstract Future 
(Type class & Implicit) 
• Akka master/worker pattern 
• Monitoring Akka with Kamon
Best Practices? 
• https://github.com/alexandru/ 
scala-best-practices 
• So many “MUST NOT, SHOULD NOT” 
• In my opinion, Trial and Error to 
find right patterns
We are Hiring! 
• 一緒に働く仲間を募集しています! 
Scalaに興味のある方はぜひ! 
adtech_scala@cyberagent.co.jp
Thanks 
han_sangwon@cyberagent.co.jp

More Related Content

What's hot

Type-safe front-end development with Scala
Type-safe front-end development with ScalaType-safe front-end development with Scala
Type-safe front-end development with Scala
takezoe
 

What's hot (20)

Rapid API Development with LoopBack/StrongLoop
Rapid API Development with LoopBack/StrongLoopRapid API Development with LoopBack/StrongLoop
Rapid API Development with LoopBack/StrongLoop
 
Infrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with GitInfrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with Git
 
Working with LoopBack Models
Working with LoopBack ModelsWorking with LoopBack Models
Working with LoopBack Models
 
Type-safe front-end development with Scala
Type-safe front-end development with ScalaType-safe front-end development with Scala
Type-safe front-end development with Scala
 
Cooking your Ravioli "al dente" with Hexagonal Architecture
Cooking your Ravioli "al dente" with Hexagonal ArchitectureCooking your Ravioli "al dente" with Hexagonal Architecture
Cooking your Ravioli "al dente" with Hexagonal Architecture
 
Jasmine - A BDD test framework for JavaScript
Jasmine - A BDD test framework for JavaScriptJasmine - A BDD test framework for JavaScript
Jasmine - A BDD test framework for JavaScript
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0
 
C* Summit 2013: Cassandra on Cloud Foundry by Renat Khasanshyn and Cornelia D...
C* Summit 2013: Cassandra on Cloud Foundry by Renat Khasanshyn and Cornelia D...C* Summit 2013: Cassandra on Cloud Foundry by Renat Khasanshyn and Cornelia D...
C* Summit 2013: Cassandra on Cloud Foundry by Renat Khasanshyn and Cornelia D...
 
Scal`a`ngular - Scala and Angular
Scal`a`ngular - Scala and AngularScal`a`ngular - Scala and Angular
Scal`a`ngular - Scala and Angular
 
Capybara
CapybaraCapybara
Capybara
 
AWS re:Invent 2016: The Effective AWS CLI User (DEV402)
AWS re:Invent 2016: The Effective AWS CLI User (DEV402)AWS re:Invent 2016: The Effective AWS CLI User (DEV402)
AWS re:Invent 2016: The Effective AWS CLI User (DEV402)
 
Iac :: Lessons Learned from Dev to Ops
Iac :: Lessons Learned from Dev to OpsIac :: Lessons Learned from Dev to Ops
Iac :: Lessons Learned from Dev to Ops
 
How You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionHow You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in Production
 
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
How to generate a REST CXF3 application from Swagger ApacheConEU 2016How to generate a REST CXF3 application from Swagger ApacheConEU 2016
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
 
Ruby performance - The low hanging fruit
Ruby performance - The low hanging fruitRuby performance - The low hanging fruit
Ruby performance - The low hanging fruit
 
Capybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automationCapybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automation
 
AWS Step Functions를 이용한 마이크로서비스 개발하기 - 김현민 (4CSoft)
AWS Step Functions를 이용한 마이크로서비스 개발하기 - 김현민 (4CSoft)AWS Step Functions를 이용한 마이크로서비스 개발하기 - 김현민 (4CSoft)
AWS Step Functions를 이용한 마이크로서비스 개발하기 - 김현민 (4CSoft)
 
OSGi with the Spring Framework
OSGi with the Spring FrameworkOSGi with the Spring Framework
OSGi with the Spring Framework
 
Introduction to GraphQL in Scala (ScalaMatsuri 2017)
Introduction to GraphQL in Scala (ScalaMatsuri 2017)Introduction to GraphQL in Scala (ScalaMatsuri 2017)
Introduction to GraphQL in Scala (ScalaMatsuri 2017)
 
CQ5 and Sling overview
CQ5 and Sling overviewCQ5 and Sling overview
CQ5 and Sling overview
 

Similar to アドテク×Scala @Dynalyst

Continuous Evaluation of Deployed Models in Production Many high-tech industr...
Continuous Evaluation of Deployed Models in Production Many high-tech industr...Continuous Evaluation of Deployed Models in Production Many high-tech industr...
Continuous Evaluation of Deployed Models in Production Many high-tech industr...
Databricks
 
Pradeep Kumar _Profile
Pradeep Kumar _ProfilePradeep Kumar _Profile
Pradeep Kumar _Profile
Pradeep Kumar
 

Similar to アドテク×Scala @Dynalyst (20)

A Practical Deep Dive into Observability of Streaming Applications with Kosta...
A Practical Deep Dive into Observability of Streaming Applications with Kosta...A Practical Deep Dive into Observability of Streaming Applications with Kosta...
A Practical Deep Dive into Observability of Streaming Applications with Kosta...
 
Evolving big microservice architectures
Evolving big microservice architecturesEvolving big microservice architectures
Evolving big microservice architectures
 
Service Virtualization - Next Gen Testing Conference Singapore 2013
Service Virtualization - Next Gen Testing Conference Singapore 2013Service Virtualization - Next Gen Testing Conference Singapore 2013
Service Virtualization - Next Gen Testing Conference Singapore 2013
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Dubbo and Weidian's practice on micro-service architecture
Dubbo and Weidian's practice on micro-service architectureDubbo and Weidian's practice on micro-service architecture
Dubbo and Weidian's practice on micro-service architecture
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)
 
Building a Data Warehouse for Business Analytics using Spark SQL-(Blagoy Kalo...
Building a Data Warehouse for Business Analytics using Spark SQL-(Blagoy Kalo...Building a Data Warehouse for Business Analytics using Spark SQL-(Blagoy Kalo...
Building a Data Warehouse for Business Analytics using Spark SQL-(Blagoy Kalo...
 
Continuous Evaluation of Deployed Models in Production Many high-tech industr...
Continuous Evaluation of Deployed Models in Production Many high-tech industr...Continuous Evaluation of Deployed Models in Production Many high-tech industr...
Continuous Evaluation of Deployed Models in Production Many high-tech industr...
 
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 
Pradeep Kumar _Profile
Pradeep Kumar _ProfilePradeep Kumar _Profile
Pradeep Kumar _Profile
 
How Totango uses Apache Spark
How Totango uses Apache SparkHow Totango uses Apache Spark
How Totango uses Apache Spark
 
(ARC309) Getting to Microservices: Cloud Architecture Patterns
(ARC309) Getting to Microservices: Cloud Architecture Patterns(ARC309) Getting to Microservices: Cloud Architecture Patterns
(ARC309) Getting to Microservices: Cloud Architecture Patterns
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .Net
 
Patterns and practices for real-world event-driven microservices by Rachel Re...
Patterns and practices for real-world event-driven microservices by Rachel Re...Patterns and practices for real-world event-driven microservices by Rachel Re...
Patterns and practices for real-world event-driven microservices by Rachel Re...
 
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesPatterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservices
 
Building Real time Application with Azure SignalR Service
Building Real time Application with Azure SignalR ServiceBuilding Real time Application with Azure SignalR Service
Building Real time Application with Azure SignalR Service
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 

Recently uploaded

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 

アドテク×Scala @Dynalyst

  • 2. Who Am I • Now: Dynalyst • Lang: Korean(30+ years) Japanese(8+ years) JAVA(8.2+ years) Scala(a year) • AdTech: AMoAd DSP CAA Reward
  • 3. What Dynalyst • Dynamic Retargeting + Analyst • ユーザーの趣味嗜好に適した広告配 信を行う国内初のスマートフォンに 特化したダイナミックリターゲティ ング広告
  • 5. Today’s Talk •How to build Spray •How to build Akka •How to Monitor them
  • 6. continuous importing D mark ad bid imp click cv redshift request logging importing stored tracking
  • 7. continuous reporting D redshift date imp click cv 2014/09 10,000 500 10 2014/08 15,000 700 25 reporting & stored summaring bidding optimization
  • 9. What is Spray? http://spray.io
  • 10. What is Spray? spray is an open-source toolkit for building REST/HTTP-based integration layers on top of Scala and Akka. Being asynchronous, actor-based, fast, lightweight, modular and testable it's a great way to connect your Scala applications to the world.
  • 12. Future[T] implicit val ec: ExecutionContext val f = Future { “hello world” } // Future[String]
  • 13. Future[T] implicit val ec: ExecutionContext for { greeting ← Future(“hello world”) name ← Future(“Han”) } yield s”$greeting, $name” // Future[String]
  • 14. FutureDirectives • spray-routing directives • non-blocking actor thread
  • 15. FutureDirectives def onComplete[T] (future: ⇒ Future[T]) (implicit ec: ExecutionContext) :Directive1[Try[T]]
  • 16. FutureDirectives implicit val ec: ExecutionContext def respondWithBidding = { onComplete(bidding) { case Success(bid: Bid) ⇒ … case Success(noBid: NoBid) ⇒ … case Failure(e) ⇒ … } }
  • 17. Type of bidding def bidding:Future[A<:BidResponse]
  • 18. Implementation def bidding:Future[A<:BidResponse] ! • simple but bad implementation Future { // All bidding computations :( }
  • 19. Application Layers Spray Router Handle raw level http request & response Bidding Business Logic External Resources" Fetch bidding candidates from data stores
  • 20. Application Layers Global Dispatcher Spray Router Handle raw level http request & response Bidding Business Logic External Resources" Fetch bidding candidates from data stores
  • 21. Application Layers Spray Router Handle raw level http request & response Bidding Business Logic External Resources" Router Dispatcher Service Dispatcher Fetch bidding candidates from data stores Repository Dispatcher
  • 22. Implementation trait Router { implicit val ec = RouterDispatcher def handle: Future[BidResponse] } trait Service { implicit val ec = ServiceDispatcher def bidding: Future[Bidder] } trait Repository { implicit val ec = RepositoryDispatcher def candidates: Future[List[Candidate]] }
  • 23. How to test those Future[T] things • Specs2 - Matcher[Future[T]] bidding must beEqual(expected).await bidding must beEqual(expected).await ( retries = 2, timeout = 100.millis )
  • 25. Abstract Future trait Router[M[_]] { implicit val M: Monad[M] def handle: M[BidResponse] } trait Service[M[_]] { implicit val M: Monad[M] def bidding: M[Bidder] = M.point(bidder) def bidder = … } trait Repository[M[_]] { implicit val M: Monad[M] def candidates: M[List[Candidate]] }
  • 26. Type class & Implicit object Service { implicit def fs = new Service[Future] { implicit val ec = ServiceDispatcher val M = Monad[Future] } implicit def ids = new Service[Id] { val M = Monad[Id] } } // type Id[+A] = A
  • 27. Test Again val s = Service.ids s.bidding must beEqual(expected)
  • 28. M[_] for Monad • Monad is a structure that represents computations defined as sequences of steps • Don’t dive into “Monad” here!
  • 29. What about Akka? http://akka.io
  • 30. continuous importing D redshift mark ad bid imp click cv request logging importing stored tracking
  • 31. continuous reporting D redshift date imp click cv 2014/09 10,000 500 10 2014/08 15,000 700 25 reporting & stored summaring bidding optimization
  • 35. How to Monitor Akka • Typesafe Console http://resources.typesafe.com/docs/ console/manual/overview.html • Kamon http://kamon.io/
  • 36. Typesafe console • Great user interface • Support by Typesafe • Expensive
  • 37. Kamon • Open Source - Free • Metrics: Akka, Spray, Play (over 50 categories) • StatsD, New Relic, Datadog • Migration could be hard
  • 40. Summary • Future Directive on Spray • Abstract Future (Type class & Implicit) • Akka master/worker pattern • Monitoring Akka with Kamon
  • 41. Best Practices? • https://github.com/alexandru/ scala-best-practices • So many “MUST NOT, SHOULD NOT” • In my opinion, Trial and Error to find right patterns
  • 42. We are Hiring! • 一緒に働く仲間を募集しています! Scalaに興味のある方はぜひ! adtech_scala@cyberagent.co.jp