SlideShare a Scribd company logo
Nexthink Library
in Scala
Implementation & Techniques
Replacing a Ruby on Rails Application with
Scala / Spray
Matthew Farwell
Senior Developer @ Nexthink in Lausanne
Java / Scala / JVM
Project lead on Scalastyle, the style checker for Scala
Contributor to other open source projects, JUnit
Co-author of “sbt in Action” with Josh Suereth
The Nexthink Library
The Nexthink Library
Project Goals
To rewrite the existing Ruby on Rails Library
To make it more ‘mainstream’ in the company
Increase the truck number
Have adequate performance for the future.
Assess technologies:
– Spray for web container, async, non-blocking
– Slick for database access (instead of Hibernate)
– Gatling for performance tests
– Angular JS for front end
Existing solution
Split into two parts:
API used by Finder and Portal, both GET and POST
5 different types of request
Administration section, for updating content
Requirements
– For the API, it must do exactly the same as the
legacy.
– The admin section can be improved if we want
Approach
A single rest server which serves both the API and the
admin screens (Spray)
The admin screens use Angular JS, which themselves
use the REST APIs
Server is stateless, therefore no sessions, etc.
Text search uses Lucene
Spray
Spray is a DSL to describe a REST API along with the
actions. It is a mixture of directives and actions:
path("1" / "ping") {
get {
respondWithMediaType(`application/json`) {
complete {
Ping(Settings.config.hostname, databaseOk())
}
}
}
}
implicit val pingFormat = jsonFormat2(Ping)
Spray
It makes things easy to do asynchronously and non-
blocking:
complete {
future {
val u = entityService.update(id, obj, user)
future { LibraryApi.refreshCache }
u
}
}
complete {
pipeline(Get("http://google.com"))
}
Testing with comparison
API Testing
We can test the new library by comparing directly with
the legacy library. So how do we generate the test
cases? We can:
use the access log for the legacy library to get a typical set of
requests
generate test cases using Scalacheck
Scalacheck
Scalacheck allows you to generate data for tests
It can generate random structured data
It then calls the Method Under Test and compares the result
using properties
It can then ‘reduce’ the use case to the smallest size which fails
In our case, we only use the generation methods
Scalacheck example
This generates one type of request:
val gen: Gen[Parameters] = for {
elementTypes <- Gen.oneOf("alert", "investigation")
tag <- Gen.containerOf[List, String](
Gen.oneOf("", "cloud", "security"))
version <- Gen.oneOf("", "3.1", "4", "5")
} yield Parameters("categories", 100, tag, elementTypes,
version, license)
We run this 5000 times per type of request for our basic tests.
Scalacheck is very good for exploring an API and finding edge cases.
Proxy/Comparison
Proxy/Comparison
The new library proxies the legacy. When we call the
legacy (non-blocking), we return those results.
When we return the results, we asynchronously compare
the results with the new library.
We can put this into production without fear
complete {
val f = pipeline(Get(legacyUrl(params)))
f onComplete { result =>
compare(result, localApi(params))
}
f
}
Proxy/Comparison
If there is a comparison failure, we store the parameters
that failed, which we can access from the FE.
We record all of the parameters from a GET or a POST.
We can also replay a failure
This approach means that we have to share the
database – so we didn't change it at all.
We had different comparison strategies depending upon
the type of API call.
Some numbers
Legacy RoR
~3400 lines (.rb, .erb, .xml.builder)
New:
~3400 lines Scala (500 lines comparison/proxy)
~1000 lines JavaScript (Angular JS)
~650 lines HTML
Spring app (similar) backend with DB: ~9000 lines Java
Frontend (GWT): ~16000 lines Java
Performance Tests – Gatling
Define a scenario:
val scn = scenario("basic usage")
.group("search") {
repeat(100) {
exec(http("google").get("http://google.com"))
.pause(0 milliseconds, 2 milliseconds)
.exec(http("yahoo").get("http://yahoo.com"))
}
}
Performance Tests – Gatling
Execute it:
setUp(scn.inject(ramp(10 users) over (10 seconds)))
.protocols(httpConf)
.assertions(
global.successfulRequests.percent.is(100),
details("search"/"google").responseTime.max.lessThan(100),
details("search"/"yahoo").responseTime.max.lessThan(100))
Gatling
Performance – RoR baseline
5 Users, 5 times, 10 requests == 250 requests
Total time: 227 seconds, req/s = 1
Caveats: unstable setup, production (single request) was
faster x 10
Mean Max
search 7600 8900
featured 2500 3200
copy 6300 7000
Performance – New
5 Users, 5 times, 10 requests == 250 requests
Total time: 5 seconds, req/s = 50
Mean Max
search 11 30
featured 5 10
copy 0 0
Performance – New
100 Users, 100 times, 10 requests == 100,000 requests
Total time: 28 seconds, req/s = 3571
3571 req/s == 300,000,000 / day
Mean Max
search 33 660
featured 24 500
copy 22 460
Performance – New
1000 Users, 100 times, 10 requests == 1,000,000 requests
Total time: 280 seconds, req/s = 3564
Required: 150-160k / day
We can support 1 day’s traffic in < 1 minute. We have
room for expansion :-)
Mean Max
search 383 15400
featured 259 23510
copy 260 33310
Some interesting numbers
Number of failures during performance tests: 0
This means that the system is very stable.
The throughput for 100 concurrent users (3571 req/s) is
about the same as for 1000 concurrent users (3564
req/s), but each request takes longer when there are
1000 concurrent users.
This is due to back pressure.
Production
Production: April 2014
Proxies were in place 6-8 weeks
Bugs found:
1 - incorrect version (attribute value) returned
2 – Finder was using empty url as a ping
3 – incorrect data returned (cause: data in database)
4 – encoding problem
Conclusion
Scala (language and tools)
compilation slow, tooling great (sbt & worksheet)
Spray
easy to use, simple to extend, no real ‘magic’
Scalacheck
very good for exploring an API, and finding edge cases, good for
data oriented testing
Slick
– easy to use, we were only doing simple things, but very similar
to working with direct SQL.
Conclusion
Angular JS
Great. Better than some of the other solutions we've had.
Async / non-blocking
Fairly easy to manage in Scala, harder in Java. Harder when
dealing with databases and non-web services.
Gatling
Great. Simple and easy. Miles better than the alternatives
(JMeter for example)
Questions?
Twitter: @matthewfarwell
Scalastyle: @scalastyle http://www.scalastyle.org
Sbt in Action:
https://www.manning.com/books/sbt-in-action
Nexthink are hiring! http://www.nexthink.com
Ad

More Related Content

What's hot (20)

vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
Andres Almiray
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page Objects
Sauce Labs
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
Abhijeet Vaikar
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
Joe Ferguson
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
Sencha
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
Knoldus Inc.
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
Timothy Oxley
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
Alan Parkinson
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Testing Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS CurriculumTesting Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS Curriculum
Brian Jordan
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
Jonathan Holloway
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Trey Howard
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
Rasheed Waraich
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
Seth McLaughlin
 
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
Azukisoft Pte Ltd
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
Addy Osmani
 
Automated testing with Drupal
Automated testing with DrupalAutomated testing with Drupal
Automated testing with Drupal
Promet Source
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
Andres Almiray
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page Objects
Sauce Labs
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
Joe Ferguson
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
Sencha
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
Knoldus Inc.
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
Timothy Oxley
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
Alan Parkinson
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
Nir Kaufman
 
Testing Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS CurriculumTesting Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS Curriculum
Brian Jordan
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
Jonathan Holloway
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Trey Howard
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
Rasheed Waraich
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
Seth McLaughlin
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
Addy Osmani
 
Automated testing with Drupal
Automated testing with DrupalAutomated testing with Drupal
Automated testing with Drupal
Promet Source
 

Viewers also liked (20)

Mobile and apps in corporate communications
Mobile and apps in corporate communicationsMobile and apps in corporate communications
Mobile and apps in corporate communications
Comprend
 
Volunteering work opportunities in Thailand | Volunteering Solutions
Volunteering work opportunities in Thailand | Volunteering SolutionsVolunteering work opportunities in Thailand | Volunteering Solutions
Volunteering work opportunities in Thailand | Volunteering Solutions
Volunteering Solutions
 
10 Best Ways to Engage and Connect with Employees
10 Best Ways to Engage and Connect with Employees10 Best Ways to Engage and Connect with Employees
10 Best Ways to Engage and Connect with Employees
David Grossman
 
Staying ahead of the curve (Digital Corporate Communications)
Staying ahead of the curve (Digital Corporate Communications)Staying ahead of the curve (Digital Corporate Communications)
Staying ahead of the curve (Digital Corporate Communications)
Staffan Lindgren
 
Modelos de negócios - Aula 1
Modelos de negócios - Aula 1Modelos de negócios - Aula 1
Modelos de negócios - Aula 1
Jornalismo Digital
 
Leadership Insights From TED 2016: Dream
Leadership Insights From TED 2016: DreamLeadership Insights From TED 2016: Dream
Leadership Insights From TED 2016: Dream
TINYpulse Employee Engagement Surveys
 
Manufacturing pov jeff green 2016 v2
Manufacturing pov jeff green 2016 v2Manufacturing pov jeff green 2016 v2
Manufacturing pov jeff green 2016 v2
Jeff Green
 
Sitrion ONE Tour - Mobile Moments - Dec 2014
Sitrion ONE Tour - Mobile Moments - Dec 2014Sitrion ONE Tour - Mobile Moments - Dec 2014
Sitrion ONE Tour - Mobile Moments - Dec 2014
Sitrion
 
Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...
Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...
Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...
SocialChorus
 
Millennials in the Workplace: It's Time to Think Differently About Employee C...
Millennials in the Workplace: It's Time to Think Differently About Employee C...Millennials in the Workplace: It's Time to Think Differently About Employee C...
Millennials in the Workplace: It's Time to Think Differently About Employee C...
Navera
 
Volunteering opportunities in india | Volunteering Solutions
Volunteering opportunities in india | Volunteering SolutionsVolunteering opportunities in india | Volunteering Solutions
Volunteering opportunities in india | Volunteering Solutions
Volunteering Solutions
 
Angel hack presentation
Angel hack presentationAngel hack presentation
Angel hack presentation
Caroline Balinska
 
MiTiN 2013 Keynote in Detroit Michigan
MiTiN 2013 Keynote in Detroit MichiganMiTiN 2013 Keynote in Detroit Michigan
MiTiN 2013 Keynote in Detroit Michigan
Kirti Vashee
 
Knowledge transfers within the Organizations
Knowledge transfers within the OrganizationsKnowledge transfers within the Organizations
Knowledge transfers within the Organizations
Dieter Hovorka
 
Internal Communication as a key competency of Customer Centricity and Custome...
Internal Communication as a key competency of Customer Centricity and Custome...Internal Communication as a key competency of Customer Centricity and Custome...
Internal Communication as a key competency of Customer Centricity and Custome...
Alexander Stoter
 
Nexthink-See your infrastructure as never before!!
Nexthink-See your infrastructure as never before!!Nexthink-See your infrastructure as never before!!
Nexthink-See your infrastructure as never before!!
rolandpiedl
 
How Reebok Uses Employee Generated Content to Amplify Advocacy
How Reebok Uses Employee Generated Content to Amplify Advocacy How Reebok Uses Employee Generated Content to Amplify Advocacy
How Reebok Uses Employee Generated Content to Amplify Advocacy
SocialChorus
 
Measuring employee engagement
Measuring employee engagementMeasuring employee engagement
Measuring employee engagement
Kevin Ruck
 
Closing the Gap: A Look At Technology in Corporate Communications
Closing the Gap: A Look At Technology in Corporate CommunicationsClosing the Gap: A Look At Technology in Corporate Communications
Closing the Gap: A Look At Technology in Corporate Communications
SocialChorus
 
Mobile and apps in corporate communications
Mobile and apps in corporate communicationsMobile and apps in corporate communications
Mobile and apps in corporate communications
Comprend
 
Volunteering work opportunities in Thailand | Volunteering Solutions
Volunteering work opportunities in Thailand | Volunteering SolutionsVolunteering work opportunities in Thailand | Volunteering Solutions
Volunteering work opportunities in Thailand | Volunteering Solutions
Volunteering Solutions
 
10 Best Ways to Engage and Connect with Employees
10 Best Ways to Engage and Connect with Employees10 Best Ways to Engage and Connect with Employees
10 Best Ways to Engage and Connect with Employees
David Grossman
 
Staying ahead of the curve (Digital Corporate Communications)
Staying ahead of the curve (Digital Corporate Communications)Staying ahead of the curve (Digital Corporate Communications)
Staying ahead of the curve (Digital Corporate Communications)
Staffan Lindgren
 
Manufacturing pov jeff green 2016 v2
Manufacturing pov jeff green 2016 v2Manufacturing pov jeff green 2016 v2
Manufacturing pov jeff green 2016 v2
Jeff Green
 
Sitrion ONE Tour - Mobile Moments - Dec 2014
Sitrion ONE Tour - Mobile Moments - Dec 2014Sitrion ONE Tour - Mobile Moments - Dec 2014
Sitrion ONE Tour - Mobile Moments - Dec 2014
Sitrion
 
Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...
Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...
Take a Trip with Employee Advocacy: How TripIt Relies on Employees to Promote...
SocialChorus
 
Millennials in the Workplace: It's Time to Think Differently About Employee C...
Millennials in the Workplace: It's Time to Think Differently About Employee C...Millennials in the Workplace: It's Time to Think Differently About Employee C...
Millennials in the Workplace: It's Time to Think Differently About Employee C...
Navera
 
Volunteering opportunities in india | Volunteering Solutions
Volunteering opportunities in india | Volunteering SolutionsVolunteering opportunities in india | Volunteering Solutions
Volunteering opportunities in india | Volunteering Solutions
Volunteering Solutions
 
MiTiN 2013 Keynote in Detroit Michigan
MiTiN 2013 Keynote in Detroit MichiganMiTiN 2013 Keynote in Detroit Michigan
MiTiN 2013 Keynote in Detroit Michigan
Kirti Vashee
 
Knowledge transfers within the Organizations
Knowledge transfers within the OrganizationsKnowledge transfers within the Organizations
Knowledge transfers within the Organizations
Dieter Hovorka
 
Internal Communication as a key competency of Customer Centricity and Custome...
Internal Communication as a key competency of Customer Centricity and Custome...Internal Communication as a key competency of Customer Centricity and Custome...
Internal Communication as a key competency of Customer Centricity and Custome...
Alexander Stoter
 
Nexthink-See your infrastructure as never before!!
Nexthink-See your infrastructure as never before!!Nexthink-See your infrastructure as never before!!
Nexthink-See your infrastructure as never before!!
rolandpiedl
 
How Reebok Uses Employee Generated Content to Amplify Advocacy
How Reebok Uses Employee Generated Content to Amplify Advocacy How Reebok Uses Employee Generated Content to Amplify Advocacy
How Reebok Uses Employee Generated Content to Amplify Advocacy
SocialChorus
 
Measuring employee engagement
Measuring employee engagementMeasuring employee engagement
Measuring employee engagement
Kevin Ruck
 
Closing the Gap: A Look At Technology in Corporate Communications
Closing the Gap: A Look At Technology in Corporate CommunicationsClosing the Gap: A Look At Technology in Corporate Communications
Closing the Gap: A Look At Technology in Corporate Communications
SocialChorus
 
Ad

Similar to Nexthink Library - replacing a ruby on rails application with Scala and Spray (20)

Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
Ken Coenen
 
Extending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsExtending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on Rails
Raimonds Simanovskis
 
Getting started with Apollo Client and GraphQL
Getting started with Apollo Client and GraphQLGetting started with Apollo Client and GraphQL
Getting started with Apollo Client and GraphQL
Morgan Dedmon
 
RSpec and Rails
RSpec and RailsRSpec and Rails
RSpec and Rails
Alan Hecht
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
PatchSpace Ltd
 
Overhauling a database engine in 2 months
Overhauling a database engine in 2 monthsOverhauling a database engine in 2 months
Overhauling a database engine in 2 months
Max Neunhöffer
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
 
Unit testing of spark applications
Unit testing of spark applicationsUnit testing of spark applications
Unit testing of spark applications
Knoldus Inc.
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
Expanding beyond SPL -- More language support in IBM Streams V4.1
Expanding beyond SPL -- More language support in IBM Streams V4.1Expanding beyond SPL -- More language support in IBM Streams V4.1
Expanding beyond SPL -- More language support in IBM Streams V4.1
lisanl
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
Altoros
 
Gatling - Stress test tool
Gatling - Stress test toolGatling - Stress test tool
Gatling - Stress test tool
Knoldus Inc.
 
AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09
Chris Purrington
 
Programming in Spark - Lessons Learned in OpenAire project
Programming in Spark - Lessons Learned in OpenAire projectProgramming in Spark - Lessons Learned in OpenAire project
Programming in Spark - Lessons Learned in OpenAire project
Łukasz Dumiszewski
 
Donald Ferguson - Old Programmers Can Learn New Tricks
Donald Ferguson - Old Programmers Can Learn New TricksDonald Ferguson - Old Programmers Can Learn New Tricks
Donald Ferguson - Old Programmers Can Learn New Tricks
ServerlessConf
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
Sudha Hari Tech Solution Pvt ltd
 
Oracle application testing suite (OATS)
Oracle application testing suite (OATS)Oracle application testing suite (OATS)
Oracle application testing suite (OATS)
Koushik Arvapally
 
Apache® Spark™ 1.6 presented by Databricks co-founder Patrick Wendell
Apache® Spark™ 1.6 presented by Databricks co-founder Patrick WendellApache® Spark™ 1.6 presented by Databricks co-founder Patrick Wendell
Apache® Spark™ 1.6 presented by Databricks co-founder Patrick Wendell
Databricks
 
Scala45 spray test
Scala45 spray testScala45 spray test
Scala45 spray test
kopiczko
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Lars Vogel
 
Extending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsExtending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on Rails
Raimonds Simanovskis
 
Getting started with Apollo Client and GraphQL
Getting started with Apollo Client and GraphQLGetting started with Apollo Client and GraphQL
Getting started with Apollo Client and GraphQL
Morgan Dedmon
 
RSpec and Rails
RSpec and RailsRSpec and Rails
RSpec and Rails
Alan Hecht
 
Overhauling a database engine in 2 months
Overhauling a database engine in 2 monthsOverhauling a database engine in 2 months
Overhauling a database engine in 2 months
Max Neunhöffer
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
 
Unit testing of spark applications
Unit testing of spark applicationsUnit testing of spark applications
Unit testing of spark applications
Knoldus Inc.
 
Expanding beyond SPL -- More language support in IBM Streams V4.1
Expanding beyond SPL -- More language support in IBM Streams V4.1Expanding beyond SPL -- More language support in IBM Streams V4.1
Expanding beyond SPL -- More language support in IBM Streams V4.1
lisanl
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
Altoros
 
Gatling - Stress test tool
Gatling - Stress test toolGatling - Stress test tool
Gatling - Stress test tool
Knoldus Inc.
 
AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09
Chris Purrington
 
Programming in Spark - Lessons Learned in OpenAire project
Programming in Spark - Lessons Learned in OpenAire projectProgramming in Spark - Lessons Learned in OpenAire project
Programming in Spark - Lessons Learned in OpenAire project
Łukasz Dumiszewski
 
Donald Ferguson - Old Programmers Can Learn New Tricks
Donald Ferguson - Old Programmers Can Learn New TricksDonald Ferguson - Old Programmers Can Learn New Tricks
Donald Ferguson - Old Programmers Can Learn New Tricks
ServerlessConf
 
Oracle application testing suite (OATS)
Oracle application testing suite (OATS)Oracle application testing suite (OATS)
Oracle application testing suite (OATS)
Koushik Arvapally
 
Apache® Spark™ 1.6 presented by Databricks co-founder Patrick Wendell
Apache® Spark™ 1.6 presented by Databricks co-founder Patrick WendellApache® Spark™ 1.6 presented by Databricks co-founder Patrick Wendell
Apache® Spark™ 1.6 presented by Databricks co-founder Patrick Wendell
Databricks
 
Scala45 spray test
Scala45 spray testScala45 spray test
Scala45 spray test
kopiczko
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Lars Vogel
 
Ad

Recently uploaded (20)

Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 

Nexthink Library - replacing a ruby on rails application with Scala and Spray

  • 1. Nexthink Library in Scala Implementation & Techniques Replacing a Ruby on Rails Application with Scala / Spray
  • 2. Matthew Farwell Senior Developer @ Nexthink in Lausanne Java / Scala / JVM Project lead on Scalastyle, the style checker for Scala Contributor to other open source projects, JUnit Co-author of “sbt in Action” with Josh Suereth
  • 5. Project Goals To rewrite the existing Ruby on Rails Library To make it more ‘mainstream’ in the company Increase the truck number Have adequate performance for the future. Assess technologies: – Spray for web container, async, non-blocking – Slick for database access (instead of Hibernate) – Gatling for performance tests – Angular JS for front end
  • 6. Existing solution Split into two parts: API used by Finder and Portal, both GET and POST 5 different types of request Administration section, for updating content Requirements – For the API, it must do exactly the same as the legacy. – The admin section can be improved if we want
  • 7. Approach A single rest server which serves both the API and the admin screens (Spray) The admin screens use Angular JS, which themselves use the REST APIs Server is stateless, therefore no sessions, etc. Text search uses Lucene
  • 8. Spray Spray is a DSL to describe a REST API along with the actions. It is a mixture of directives and actions: path("1" / "ping") { get { respondWithMediaType(`application/json`) { complete { Ping(Settings.config.hostname, databaseOk()) } } } } implicit val pingFormat = jsonFormat2(Ping)
  • 9. Spray It makes things easy to do asynchronously and non- blocking: complete { future { val u = entityService.update(id, obj, user) future { LibraryApi.refreshCache } u } } complete { pipeline(Get("http://google.com")) }
  • 11. API Testing We can test the new library by comparing directly with the legacy library. So how do we generate the test cases? We can: use the access log for the legacy library to get a typical set of requests generate test cases using Scalacheck
  • 12. Scalacheck Scalacheck allows you to generate data for tests It can generate random structured data It then calls the Method Under Test and compares the result using properties It can then ‘reduce’ the use case to the smallest size which fails In our case, we only use the generation methods
  • 13. Scalacheck example This generates one type of request: val gen: Gen[Parameters] = for { elementTypes <- Gen.oneOf("alert", "investigation") tag <- Gen.containerOf[List, String]( Gen.oneOf("", "cloud", "security")) version <- Gen.oneOf("", "3.1", "4", "5") } yield Parameters("categories", 100, tag, elementTypes, version, license) We run this 5000 times per type of request for our basic tests. Scalacheck is very good for exploring an API and finding edge cases.
  • 15. Proxy/Comparison The new library proxies the legacy. When we call the legacy (non-blocking), we return those results. When we return the results, we asynchronously compare the results with the new library. We can put this into production without fear complete { val f = pipeline(Get(legacyUrl(params))) f onComplete { result => compare(result, localApi(params)) } f }
  • 16. Proxy/Comparison If there is a comparison failure, we store the parameters that failed, which we can access from the FE. We record all of the parameters from a GET or a POST. We can also replay a failure This approach means that we have to share the database – so we didn't change it at all. We had different comparison strategies depending upon the type of API call.
  • 17. Some numbers Legacy RoR ~3400 lines (.rb, .erb, .xml.builder) New: ~3400 lines Scala (500 lines comparison/proxy) ~1000 lines JavaScript (Angular JS) ~650 lines HTML Spring app (similar) backend with DB: ~9000 lines Java Frontend (GWT): ~16000 lines Java
  • 18. Performance Tests – Gatling Define a scenario: val scn = scenario("basic usage") .group("search") { repeat(100) { exec(http("google").get("http://google.com")) .pause(0 milliseconds, 2 milliseconds) .exec(http("yahoo").get("http://yahoo.com")) } }
  • 19. Performance Tests – Gatling Execute it: setUp(scn.inject(ramp(10 users) over (10 seconds))) .protocols(httpConf) .assertions( global.successfulRequests.percent.is(100), details("search"/"google").responseTime.max.lessThan(100), details("search"/"yahoo").responseTime.max.lessThan(100)) Gatling
  • 20. Performance – RoR baseline 5 Users, 5 times, 10 requests == 250 requests Total time: 227 seconds, req/s = 1 Caveats: unstable setup, production (single request) was faster x 10 Mean Max search 7600 8900 featured 2500 3200 copy 6300 7000
  • 21. Performance – New 5 Users, 5 times, 10 requests == 250 requests Total time: 5 seconds, req/s = 50 Mean Max search 11 30 featured 5 10 copy 0 0
  • 22. Performance – New 100 Users, 100 times, 10 requests == 100,000 requests Total time: 28 seconds, req/s = 3571 3571 req/s == 300,000,000 / day Mean Max search 33 660 featured 24 500 copy 22 460
  • 23. Performance – New 1000 Users, 100 times, 10 requests == 1,000,000 requests Total time: 280 seconds, req/s = 3564 Required: 150-160k / day We can support 1 day’s traffic in < 1 minute. We have room for expansion :-) Mean Max search 383 15400 featured 259 23510 copy 260 33310
  • 24. Some interesting numbers Number of failures during performance tests: 0 This means that the system is very stable. The throughput for 100 concurrent users (3571 req/s) is about the same as for 1000 concurrent users (3564 req/s), but each request takes longer when there are 1000 concurrent users. This is due to back pressure.
  • 25. Production Production: April 2014 Proxies were in place 6-8 weeks Bugs found: 1 - incorrect version (attribute value) returned 2 – Finder was using empty url as a ping 3 – incorrect data returned (cause: data in database) 4 – encoding problem
  • 26. Conclusion Scala (language and tools) compilation slow, tooling great (sbt & worksheet) Spray easy to use, simple to extend, no real ‘magic’ Scalacheck very good for exploring an API, and finding edge cases, good for data oriented testing Slick – easy to use, we were only doing simple things, but very similar to working with direct SQL.
  • 27. Conclusion Angular JS Great. Better than some of the other solutions we've had. Async / non-blocking Fairly easy to manage in Scala, harder in Java. Harder when dealing with databases and non-web services. Gatling Great. Simple and easy. Miles better than the alternatives (JMeter for example)
  • 28. Questions? Twitter: @matthewfarwell Scalastyle: @scalastyle http://www.scalastyle.org Sbt in Action: https://www.manning.com/books/sbt-in-action Nexthink are hiring! http://www.nexthink.com

Editor's Notes

  • #2: &amp;lt;number&amp;gt;
  • #3: &amp;lt;number&amp;gt;
  • #4: &amp;lt;number&amp;gt;
  • #5: &amp;lt;number&amp;gt;
  • #6: &amp;lt;number&amp;gt;
  • #7: &amp;lt;number&amp;gt;
  • #8: &amp;lt;number&amp;gt;
  • #9: complete can return HttpResponse, a String/Byte Array, or something which can be translated into JSON. It can also return a future of all of these things. Authentication is just another directive. &amp;lt;number&amp;gt;
  • #10: complete can return HttpResponse, a String/Byte Array, or something which can be translated into JSON. It can also return a future of all of these things. Authentication is just another directive. &amp;lt;number&amp;gt;
  • #11: &amp;lt;number&amp;gt;
  • #12: &amp;lt;number&amp;gt;
  • #13: &amp;lt;number&amp;gt;
  • #14: containerOf, one of, mention frequency &amp;lt;number&amp;gt;
  • #15: Diagram here please Pipeline non-blocking, when this completes we return the response from the legacy library and then fire off a comparison. &amp;lt;number&amp;gt;
  • #16: Diagram here please Pipeline non-blocking, when this completes we return the response from the legacy library and then fire off a comparison. &amp;lt;number&amp;gt;
  • #17: Diagram here please Pipeline non-blocking, when this completes we return the response from the legacy library and then fire off a comparison. &amp;lt;number&amp;gt;
  • #18: RoR does email sending, public front end, wc -l &amp;lt;number&amp;gt;
  • #19: &amp;lt;number&amp;gt;
  • #20: &amp;lt;number&amp;gt;
  • #21: &amp;lt;number&amp;gt;
  • #22: &amp;lt;number&amp;gt;
  • #23: Calculate 3571 / 108 ~= 33 &amp;lt;number&amp;gt;
  • #24: &amp;lt;number&amp;gt;
  • #25: 145k / day == last_elements &amp;lt;number&amp;gt;
  • #26: 145k / day == last_elements &amp;lt;number&amp;gt;
  • #27: &amp;lt;number&amp;gt;
  • #28: &amp;lt;number&amp;gt;
  • #29: &amp;lt;number&amp;gt;