SlideShare una empresa de Scribd logo
1 de 25
Tomasz Lelek 
tomekl007 
@tomekl007
How to build microservices 
using Scalatra and Scala ?
Presentation plan 
1. Business context 
2. Technology 
3. Live coding 
4. Production example
Monolith
Same functionality – 
new architecture
Redirecting request
Url Rewriting 
#Apache rewrite url, work for post request 
RewriteEngine On 
RewriteRule /generate http://reportservice.no/generate [P]
Needs
and
Embedded Container
Starting Service 
./sbt 
>container:start 
[info] Started 
SelectChannelConnector@0.0.0.0:8090 
[success] Total time: 2 s
Let’s create simple project
How microservice looks like?
Using via imported client
Many clients
Scala java - interoperability
Rest, json, http
Architecture
Managing configuration
Configuration Service
Asking for configuration
Graph visualization
Circuit Breaker
Hystrix
Thank You, Questions ?

Más contenido relacionado

La actualidad más candente

SignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsSignalR: Add real-time to your applications
SignalR: Add real-time to your applications
Eugene Zharkov
 
SignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersSignalR for ASP.NET Developers
SignalR for ASP.NET Developers
Shivanand Arur
 
Building Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalRBuilding Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalR
Shravan Kumar Kasagoni
 

La actualidad más candente (20)

Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
Intro to os-faults library
Intro to os-faults libraryIntro to os-faults library
Intro to os-faults library
 
Containerize!
Containerize!Containerize!
Containerize!
 
SignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsSignalR: Add real-time to your applications
SignalR: Add real-time to your applications
 
Meteor Workshop - Open Sanca
Meteor Workshop - Open SancaMeteor Workshop - Open Sanca
Meteor Workshop - Open Sanca
 
Real time web with SignalR
Real time web with SignalRReal time web with SignalR
Real time web with SignalR
 
Real-time ASP.NET with SignalR
Real-time ASP.NET with SignalRReal-time ASP.NET with SignalR
Real-time ASP.NET with SignalR
 
SignalR with ASP.NET MVC 6
SignalR with ASP.NET MVC 6SignalR with ASP.NET MVC 6
SignalR with ASP.NET MVC 6
 
Building Real Time Web Applications with SignalR (NoVA Code Camp 2015)
Building Real Time Web Applications with SignalR (NoVA Code Camp 2015)Building Real Time Web Applications with SignalR (NoVA Code Camp 2015)
Building Real Time Web Applications with SignalR (NoVA Code Camp 2015)
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
SignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersSignalR for ASP.NET Developers
SignalR for ASP.NET Developers
 
Building Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalRBuilding Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalR
 
Getting started with ASPNET Core SignalR
Getting started with ASPNET Core SignalRGetting started with ASPNET Core SignalR
Getting started with ASPNET Core SignalR
 
Multitenant SaaS Apps In Rails By Iqbal Hasnan
Multitenant SaaS Apps In Rails By Iqbal HasnanMultitenant SaaS Apps In Rails By Iqbal Hasnan
Multitenant SaaS Apps In Rails By Iqbal Hasnan
 
Manage your APIs and Microservices with an API Gateway
Manage your APIs and Microservices with an API GatewayManage your APIs and Microservices with an API Gateway
Manage your APIs and Microservices with an API Gateway
 
Eclipse Kapua messaging refactoring proposal
Eclipse Kapua messaging refactoring proposalEclipse Kapua messaging refactoring proposal
Eclipse Kapua messaging refactoring proposal
 
Real-time Communications with SignalR
Real-time Communications with SignalRReal-time Communications with SignalR
Real-time Communications with SignalR
 
Trailblazer Rails Architecture
Trailblazer Rails ArchitectureTrailblazer Rails Architecture
Trailblazer Rails Architecture
 
Going Serverless with Iron.io
Going Serverless with Iron.ioGoing Serverless with Iron.io
Going Serverless with Iron.io
 
Api RESTFull
Api RESTFullApi RESTFull
Api RESTFull
 

Similar a Scalatra scala meetup

Testing for infra code using test-kitchen,docker,chef
Testing for infra code using  test-kitchen,docker,chefTesting for infra code using  test-kitchen,docker,chef
Testing for infra code using test-kitchen,docker,chef
kamalikamj
 
Service-Level Objective for Serverless Applications
Service-Level Objective for Serverless ApplicationsService-Level Objective for Serverless Applications
Service-Level Objective for Serverless Applications
alekn
 

Similar a Scalatra scala meetup (20)

JDD 2014 HOW TO REBUILD MONOLITHIC APPLICATION TO MICRO SERVICES ARCHITECTURE ?
JDD 2014 HOW TO REBUILD MONOLITHIC APPLICATION TO MICRO SERVICES ARCHITECTURE ?JDD 2014 HOW TO REBUILD MONOLITHIC APPLICATION TO MICRO SERVICES ARCHITECTURE ?
JDD 2014 HOW TO REBUILD MONOLITHIC APPLICATION TO MICRO SERVICES ARCHITECTURE ?
 
2019-06 - Goto Amsterdam - Microservices
2019-06 - Goto Amsterdam - Microservices2019-06 - Goto Amsterdam - Microservices
2019-06 - Goto Amsterdam - Microservices
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
03 2014 Apache Spark Serving: Unifying Batch, Streaming, and RESTful Serving
03 2014 Apache Spark Serving: Unifying Batch, Streaming, and RESTful Serving03 2014 Apache Spark Serving: Unifying Batch, Streaming, and RESTful Serving
03 2014 Apache Spark Serving: Unifying Batch, Streaming, and RESTful Serving
 
Effective Kubernetes - Is Kubernetes the new Linux? Is the new Application Se...
Effective Kubernetes - Is Kubernetes the new Linux? Is the new Application Se...Effective Kubernetes - Is Kubernetes the new Linux? Is the new Application Se...
Effective Kubernetes - Is Kubernetes the new Linux? Is the new Application Se...
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
Testing for infra code using test-kitchen,docker,chef
Testing for infra code using  test-kitchen,docker,chefTesting for infra code using  test-kitchen,docker,chef
Testing for infra code using test-kitchen,docker,chef
 
How (and why!) we built Packet
How (and why!) we built Packet  How (and why!) we built Packet
How (and why!) we built Packet
 
Service-Level Objective for Serverless Applications
Service-Level Objective for Serverless ApplicationsService-Level Objective for Serverless Applications
Service-Level Objective for Serverless Applications
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
 
Oop2008 RESTful services with GWT and Apache CXF
Oop2008 RESTful services with GWT and Apache CXFOop2008 RESTful services with GWT and Apache CXF
Oop2008 RESTful services with GWT and Apache CXF
 
Mashups
MashupsMashups
Mashups
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
 
Learn Advanced JAVA at ASIT
Learn Advanced JAVA at ASITLearn Advanced JAVA at ASIT
Learn Advanced JAVA at ASIT
 

Último

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

(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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
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
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
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
 
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...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
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...
 

Scalatra scala meetup

Notas del editor

  1. 1.Powiedz o sobie, gdzie pracuejsz, jakie projekty Witam wszystkich: nazywam się Tomasz Lelek, jestem programistą w firmie Schibsted Tech Polska. Pracuje przy projektach zwiazanych z java. Mozecie mnie znalesc na twitterze i githubue Jesli ktos bedzie mial pytania to prosze o zadawanie ich na koniec prezentacji.
  2. 2.In my presentatnion i’ll try to show, how to build microservices using scala language and scalatra framework
  3. 1, why we want build microserwice architecture ? 2.Which technologies allow us to build them realtivly simply 3.I’ll create new serivice, implement couple rest methods, write some tests, and show how easily use akka actors in that service 4.How to monitor such microservice
  4. 4.Why we even want to create architecutre of microserwices ? In a java work, often we see projects, which could be describe by one work : monolith Characteristics of arhitecure such projects is very tight coupling, where change in one place in code, could have big impanct on code in place which is totaly not connected with our change. I am working with application which could be described as Monolith
  5. 7 When we made decision to pull out some fucntionality from monolithic app into microserwice, we want to change arhictecture, in a way, which won’t be seen for a end user of our application. We want our application to work in exact same way as previosly, but handling requests of user will be done not in monoilithic application, but in new microservice. We want that change be unnoticable for end user.
  6. To be able to achive this, we use simple dispacher ( proxy). When from web application ( browser) request for doing some action which was previosuly done in monolithic app is send, that reqeust is captured by server (eg apache ) and redirect to new microserwice, which execture actions, which was previosuly executed by legacy system application.This is unnoticable for end user.
  7. 9.APACHE MOD REWRITE – it works like this : define ..
  8. 10.We want to craete miroservices, but we need proper techologies to implement such architecture. We need some light framework, which enable us to deploy application easily, quickly. Our microserwices need to be really light, and have only neccessary libraries ( in contraty ot some java framwerork ;)
  9. 11. Concepcual scalatra is based on very poprular ruby framework – sinatra. It has couple librareis, embedded container jetty, it is based on servlets, it’s written entirly in scala language. It has integrated couple useful libraries like json mapper
  10. When building microservices we want, our application to start very quickly. Best solution is using embeded container. Micorservice could not be deployd on a container (like tomcat ) which will be starting long time, we want possiliobty to take jar file with packed service, and run that service in one command. We want that to happen very quickly, becuaes it reduce feedback for a developer, therefore he could work much more effectivly. When you proggraming you service, and you need to wait 40s to see your changes, it disturbs you, you loosing you focus, and flow, therefore tou work much less effectivly. When you could seen you changes in seconds, you reduce you feedback time, you could be much more better in programming, Our service is then like a packed gift, which need only to be unpack ( run )
  11. 13. Only thing that we need to do to run our service is to Start sbt Then fire command container:start. In that moment our application is started on proper port We see that it took only 2 seconds to run that Very useful tip : ./sbt >container:start ~ ;copy-resources;aux-compile -it’ll be monitoring directory with our project, and if any file will change, it’ll restart our container
  12. Right now i’ll crate simple scalra app, and do some coding mkdir ScalatraSimpleService 502 cd Scal 503 cd ScalatraSimpleService/ 504 ls 505 g8 scalatra/scalatra-sbt 506 ls 507 cd awesomeservice/ 508 ls 509 ls 510 cd project/ 511 ls 512 cat build.properties 513 cat build.scala 514 ls 515 cat plugins.sbt 516 cd .. 517 ls 518 cat README.md 519 history ./sbt run Open configurationService, I create meetupController 1.MeetupController 2.MeetupController get test 3.Add to bootstrap 4.MeetupControler post 5.Craete RateAggregateActor, and case class MeetupRate 6.Add to bootstrap 7.Show 8.modify test
  13. 14. When we know our tool ( more or less :-) we need to think about architecture. We want our service to supply light client for other services. Then that client could be imported by other service, which could easily and transparently speak with that first service, without worring about Sending http reqeust So: Service importing client of other service, use that client like normal library, and client is responsible for sending requests to that other sercie. All that happends transaprently for serivce which import that light client. Our services consist of three componenst : proper srecvie, which works on server, it’s run as embeded container, model wich will be shared beetewen client and server ( it is used as a contract ), And third component is a mentioned light client
  14. 15. Each request to our sercie throuout client, which could be imported by another microservies. You could speak to service, also via any other http client, like curl, because each service is created according to rest -show how client looks like ( configuration service client, maybe show how i implemented caching )
  15. One microservice could supply many light clients, each is written in different language ( scala, java, js ), then other proggramer, which want create microservice in other language, or technology, when want to use that service, only need to import client, which is written in languege of his choice.
  16. I’ll show you how easiliy client written in scala language, work with java code Spid-lib -> ConfServiceFacade
  17. To that point you could see that each servie is implemented accoring to rest, using json as exhachange format, and proper use of http protocol
  18. 18.When building csv-reports-generator and need data form dataservice, we only need to import light client supplied from dataservice. Then we could easily use dataservice from csv generator transparently. We could see that architecture of microservice could easily evolve
  19. One example of microservice which we our use in production system is configruation service. It stores data about location of all microservices, and other useful things like db config, amazon sqs confiig, whatever we want
  20. Configuration service is use as a facade abouve etcd nodes. Etcd nodes are responsible for persistance of data and syncrhonization of data beetween them.
  21. 20. Main purpous behind such service, is to create centralized point with all configuration. Then we could use this as following
  22. 24. It’s a simple visualization of excerpt of achitrecutre of microservices. We see which service is currenly unavailable. Some services could sometimes went down
  23. Circuit Breaker – in such disrupted environment, failure will ocure sonner or letter. Idea behind that patter is to find about about failure very quickly, and do not repeat same action, if we know that action will cause failure Example : when we want to send requet to other microservice, we do not want our service to hang on waiting for response from the, If system to which we send reqest not responding, then we handle it in proper way, then we could react for failure very quickly In that way, we avoid cascade failure. If one service hang on waiting for response from other, that service will stop to respond itself, and it will cause another failure, in other service. It’ll be cascading failure.
  24. 29.Hystrix library go to code
  25. 42. dziekuje, jakies pytania ? link na githubie do przykladowego microserwisu, ktory to kazdy moze sobie uruchomic