SlideShare a Scribd company logo
1 of 31
Download to read offline
Efficient HTTP applications on
the JVM with Ratpack
Álvaro Sánchez-Mariscal
Software Engineer, Grails committer
Object Computing, Inc
Platinum Sponsor
#VoxxedBerlin @alvaro_sanchez
Álvaro Sánchez-Mariscal
Software Engineer
Grails Development Team
@alvaro_sanchez
sanchezmariscala@ociweb.com
OCI is the new home of Grails
More at ociweb.com/grails
Agenda
• Introduction.
• The handlers chain.
• The context.
• Ratpack modules.
• Asynchronous & Non Blocking model.
• Q&A.
Introduction
Slides, code & workshop
• Slides:
• http://bit.ly/ratpack-101-slides	
• Companion code:
• http://bit.ly/ratpack-101-code	
• Workshop:
• http://bit.ly/ratpack-101-workshop
Before we start
• Raise your hand if you have used:
• Java.
• Groovy.
• Spock.
• Ratpack?
Introduction
• Ratpack is:
• A set of Java 8 libraries…
• … lightweight, un-opinionated, Netty-based...
• … for writing non-blocking HTTP applications…
• … focused on performance and efficiency…
• … with an emphasis on testability..
• … embracing Java 8 or Groovy as programming
languages.
When to use Ratpack?
• For microservices.
• For high performance applications.
• For lightweight services (no container,
batteries included).
If you are writing
microservices, why
do you use
macroframeworks?
Ratpack is developer friendly
• Starts up in milliseconds.
• Development-time reloading (in ms) with
Gradle.
• First-class support for functional testing.
Demo
1. Groovy script.
2. Gradle build with Lazybones.
The handlers chain
Handlers
• An incoming request is passed through the
handler chain.
• A handler can:
• Respond to the request.
• Delegate to the next handler in the chain.
• Insert more handlers in the chain and delegate to
them.
Handlers
• Each handler is given a Context instance.
• To interact with the request / response objects.
• To access the registry.
• Etc.
• Note that Ratpack is not based on the
Servlet API.
Demo
3. Handlers.
The context
The Context
• The Context provides:
• Access to the HTTP Request and Response
objects.
• Interaction with other handlers through next()
and insert() methods.
• Access to objects in the registry.
The registry
• The context is also a Registry of objects.
• Handlers can store objects into the registry
for use by downstream handlers.
Demo
4. Working with the context.
Ratpack modules
Ratpack modules
• Ratpack can integrate with Google Guice
for:
• Dependency injection for services, etc.
• Officially supported modules.
• Reusing your own components as your modules.
Official modules
• Benchmarks (JMH).
• Metrics (Dropwizard).
• H2 Database.
• Handlebars.
• HikariCP JDBC pool.
• Hystrix.
• New Relic.
• Pac4J.
• RxJava.
• HTTP sessions.
• Spring Boot.
• Thymeleaf.
Demo
5. Using Guice and Jackson in Ratpack.
Asynchronous and 

non-blocking model
The classic approach
• A thread-per-request.
• There is a relatively large thread pool.
• Each request is assigned a thread from the pool.
• If the request handling code performs blocking I/O,
the thread sleeps until the result is received.
• Overhead: thread management, memory
consumption.
Ratpack’s value proposition
• HTTP IO is event-driven (non blocking).
• Powered by Netty.
• Handler chain is organised as a pipeline of
asynchronous functions.
• Small compute thread pool.
• Blocking operations are executed in a separate pool.
• Integration with existing libraries like RxJava.
Async model
• Ratpack guarantees a deterministic flow.
• Promises are executed in the order they are
defined.
• Once the promises are resolved, they are executed
in compute threads.
• Async functions can be composed.
• To avoid the callback hell.
Demo
6. Asynchronous model.
Álvaro Sánchez-Mariscal
Software Engineer
Grails Development Team
@alvaro_sanchez
sanchezmariscala@ociweb.com
Danke!

More Related Content

What's hot

Rapid application development with spring roo j-fall 2010 - baris dere
Rapid application development with spring roo   j-fall 2010 - baris dereRapid application development with spring roo   j-fall 2010 - baris dere
Rapid application development with spring roo j-fall 2010 - baris dere
Baris Dere
 

What's hot (19)

Gr8Conf 2016 - What's new in Grails 3
Gr8Conf 2016 - What's new in Grails 3Gr8Conf 2016 - What's new in Grails 3
Gr8Conf 2016 - What's new in Grails 3
 
Super Size Your Search
Super Size Your SearchSuper Size Your Search
Super Size Your Search
 
how to mesure web performance metrics
how to mesure web performance metricshow to mesure web performance metrics
how to mesure web performance metrics
 
jclouds workshop
jclouds workshopjclouds workshop
jclouds workshop
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
 
Quick dive into Ruby on Rails
Quick dive into Ruby on RailsQuick dive into Ruby on Rails
Quick dive into Ruby on Rails
 
Apache ManifoldCF @ Linux Day 2012
Apache ManifoldCF @ Linux Day 2012Apache ManifoldCF @ Linux Day 2012
Apache ManifoldCF @ Linux Day 2012
 
Apache ManifoldCF
Apache ManifoldCFApache ManifoldCF
Apache ManifoldCF
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
The ELK Stack - Get to Know Logs
The ELK Stack - Get to Know LogsThe ELK Stack - Get to Know Logs
The ELK Stack - Get to Know Logs
 
Rapid application development with spring roo j-fall 2010 - baris dere
Rapid application development with spring roo   j-fall 2010 - baris dereRapid application development with spring roo   j-fall 2010 - baris dere
Rapid application development with spring roo j-fall 2010 - baris dere
 
Fastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + SwaggerFastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + Swagger
 
JHipster
JHipsterJHipster
JHipster
 
Blazor, lo sapevi che...
Blazor, lo sapevi che...Blazor, lo sapevi che...
Blazor, lo sapevi che...
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016
 
Continuous performance management with Gatling
Continuous performance management with GatlingContinuous performance management with Gatling
Continuous performance management with Gatling
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
Easy Microservices with JHipster - Devoxx BE 2017
Easy Microservices with JHipster - Devoxx BE 2017Easy Microservices with JHipster - Devoxx BE 2017
Easy Microservices with JHipster - Devoxx BE 2017
 
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk ServerUsing ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
Using ELK-Stack (Elasticsearch, Logstash and Kibana) with BizTalk Server
 

Viewers also liked

Evaluation Question 1 (ii)
Evaluation Question 1 (ii)Evaluation Question 1 (ii)
Evaluation Question 1 (ii)
mediagroup16
 
Guido Everaert - De essentie van storytelling
Guido Everaert - De essentie van storytellingGuido Everaert - De essentie van storytelling
Guido Everaert - De essentie van storytelling
Sanoma Belgium
 
El modernismo
El modernismoEl modernismo
El modernismo
moresita
 

Viewers also liked (16)

Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
 
Roboty związane z montażem przewodów instalacji gazowych oraz podłączaniem ur...
Roboty związane z montażem przewodów instalacji gazowych oraz podłączaniem ur...Roboty związane z montażem przewodów instalacji gazowych oraz podłączaniem ur...
Roboty związane z montażem przewodów instalacji gazowych oraz podłączaniem ur...
 
Prezi vs Power Point
Prezi vs Power PointPrezi vs Power Point
Prezi vs Power Point
 
Ta emot praktikanter med uppehållstillstånd #welcometalent
Ta emot praktikanter med uppehållstillstånd #welcometalent Ta emot praktikanter med uppehållstillstånd #welcometalent
Ta emot praktikanter med uppehållstillstånd #welcometalent
 
Evaluation Question 1 (ii)
Evaluation Question 1 (ii)Evaluation Question 1 (ii)
Evaluation Question 1 (ii)
 
Daily Newsletter: 20th December, 2010
Daily Newsletter: 20th December, 2010Daily Newsletter: 20th December, 2010
Daily Newsletter: 20th December, 2010
 
Video Marketing Cycle
Video Marketing CycleVideo Marketing Cycle
Video Marketing Cycle
 
Avoiding a Lost Generation (Part2): Ten key recommendations to support youth ...
Avoiding a Lost Generation (Part2): Ten key recommendations to support youth ...Avoiding a Lost Generation (Part2): Ten key recommendations to support youth ...
Avoiding a Lost Generation (Part2): Ten key recommendations to support youth ...
 
Guido Everaert - De essentie van storytelling
Guido Everaert - De essentie van storytellingGuido Everaert - De essentie van storytelling
Guido Everaert - De essentie van storytelling
 
El modernismo
El modernismoEl modernismo
El modernismo
 
Chile contemporáneo Simon Collier
Chile contemporáneo Simon CollierChile contemporáneo Simon Collier
Chile contemporáneo Simon Collier
 
The Science of Monitoring Yourself
The Science of Monitoring YourselfThe Science of Monitoring Yourself
The Science of Monitoring Yourself
 
Wine & Web: Curation and Collaboration
Wine & Web: Curation and CollaborationWine & Web: Curation and Collaboration
Wine & Web: Curation and Collaboration
 
02 celula
02 celula02 celula
02 celula
 
Thirkell Elementary - Park West Gallery - Beyond Basics
Thirkell Elementary - Park West Gallery - Beyond BasicsThirkell Elementary - Park West Gallery - Beyond Basics
Thirkell Elementary - Park West Gallery - Beyond Basics
 
Park West Gallery New Year's Eve Fine Art Collection [2010]
Park West Gallery New Year's Eve Fine Art Collection [2010]Park West Gallery New Year's Eve Fine Art Collection [2010]
Park West Gallery New Year's Eve Fine Art Collection [2010]
 

Similar to Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016

01/2009 - Portral development with liferay
01/2009 - Portral development with liferay01/2009 - Portral development with liferay
01/2009 - Portral development with liferay
daveayan
 

Similar to Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016 (20)

JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
iSense Java Summit 2017 - Microservices in action at the Dutch National Police
iSense Java Summit 2017 - Microservices in action at the Dutch National PoliceiSense Java Summit 2017 - Microservices in action at the Dutch National Police
iSense Java Summit 2017 - Microservices in action at the Dutch National Police
 
Get There meetup March 2018 - Microservices in action at the Dutch National P...
Get There meetup March 2018 - Microservices in action at the Dutch National P...Get There meetup March 2018 - Microservices in action at the Dutch National P...
Get There meetup March 2018 - Microservices in action at the Dutch National P...
 
Dublin JUG February 2018 - Microservices in action at the Dutch National Police
Dublin JUG February 2018 - Microservices in action at the Dutch National PoliceDublin JUG February 2018 - Microservices in action at the Dutch National Police
Dublin JUG February 2018 - Microservices in action at the Dutch National Police
 
Microservices in action at the Dutch National Police
Microservices in action at the Dutch National PoliceMicroservices in action at the Dutch National Police
Microservices in action at the Dutch National Police
 
OpenValue meetup October 2017 - Microservices in action at the Dutch National...
OpenValue meetup October 2017 - Microservices in action at the Dutch National...OpenValue meetup October 2017 - Microservices in action at the Dutch National...
OpenValue meetup October 2017 - Microservices in action at the Dutch National...
 
JavaZone 2017 - Microservices in action at the Dutch National Police
JavaZone 2017 - Microservices in action at the Dutch National PoliceJavaZone 2017 - Microservices in action at the Dutch National Police
JavaZone 2017 - Microservices in action at the Dutch National Police
 
7 Apache Process Cloudstack Developer Day
7 Apache Process Cloudstack Developer Day7 Apache Process Cloudstack Developer Day
7 Apache Process Cloudstack Developer Day
 
Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
Webinar - DreamObjects/Ceph Case Study
Webinar - DreamObjects/Ceph Case StudyWebinar - DreamObjects/Ceph Case Study
Webinar - DreamObjects/Ceph Case Study
 
CodeMotion Amsterdam 2018 - Microservices in action at the Dutch National Police
CodeMotion Amsterdam 2018 - Microservices in action at the Dutch National PoliceCodeMotion Amsterdam 2018 - Microservices in action at the Dutch National Police
CodeMotion Amsterdam 2018 - Microservices in action at the Dutch National Police
 
Microservices in action at the Dutch National Police - Bert Jan Schrijver - C...
Microservices in action at the Dutch National Police - Bert Jan Schrijver - C...Microservices in action at the Dutch National Police - Bert Jan Schrijver - C...
Microservices in action at the Dutch National Police - Bert Jan Schrijver - C...
 
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National PoliceDevoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National Police
 
DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and Scala
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
01/2009 - Portral development with liferay
01/2009 - Portral development with liferay01/2009 - Portral development with liferay
01/2009 - Portral development with liferay
 
Agile sites2
Agile sites2Agile sites2
Agile sites2
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 

More from Alvaro Sanchez-Mariscal

Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 

More from Alvaro Sanchez-Mariscal (20)

Serverless functions with Micronaut
Serverless functions with MicronautServerless functions with Micronaut
Serverless functions with Micronaut
 
Asynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applicationsAsynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applications
 
6 things you need to know about GORM 6
6 things you need to know about GORM 66 things you need to know about GORM 6
6 things you need to know about GORM 6
 
Reactive microservices with Micronaut - GR8Conf EU 2018
Reactive microservices with Micronaut - GR8Conf EU 2018Reactive microservices with Micronaut - GR8Conf EU 2018
Reactive microservices with Micronaut - GR8Conf EU 2018
 
Reactive microservices with Micronaut - Greach 2018
Reactive microservices with Micronaut - Greach 2018Reactive microservices with Micronaut - Greach 2018
Reactive microservices with Micronaut - Greach 2018
 
Practical Spring Cloud
Practical Spring CloudPractical Spring Cloud
Practical Spring Cloud
 
Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016
 
Desarrollo de aplicaciones con Grails 3, Angular JS y Spring Security
Desarrollo de aplicaciones con Grails 3, Angular JS y Spring SecurityDesarrollo de aplicaciones con Grails 3, Angular JS y Spring Security
Desarrollo de aplicaciones con Grails 3, Angular JS y Spring Security
 
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
 
Mastering Grails 3 Plugins - GR8Conf US 2016
Mastering Grails 3 Plugins - GR8Conf US 2016Mastering Grails 3 Plugins - GR8Conf US 2016
Mastering Grails 3 Plugins - GR8Conf US 2016
 
Mastering Grails 3 Plugins - GR8Conf EU 2016
Mastering Grails 3 Plugins - GR8Conf EU 2016Mastering Grails 3 Plugins - GR8Conf EU 2016
Mastering Grails 3 Plugins - GR8Conf EU 2016
 
Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
 
Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015Stateless authentication for microservices - GR8Conf 2015
Stateless authentication for microservices - GR8Conf 2015
 
Ratpack 101 - GR8Conf 2015
Ratpack 101 - GR8Conf 2015Ratpack 101 - GR8Conf 2015
Ratpack 101 - GR8Conf 2015
 
Ratpack 101 - GeeCON 2015
Ratpack 101 - GeeCON 2015Ratpack 101 - GeeCON 2015
Ratpack 101 - GeeCON 2015
 
Stateless authentication for microservices - Spring I/O 2015
Stateless authentication for microservices  - Spring I/O 2015Stateless authentication for microservices  - Spring I/O 2015
Stateless authentication for microservices - Spring I/O 2015
 
Stateless authentication for microservices - Greach 2015
Stateless authentication for microservices - Greach 2015Stateless authentication for microservices - Greach 2015
Stateless authentication for microservices - Greach 2015
 
Stateless authentication for microservices applications - JavaLand 2015
Stateless authentication for microservices applications -  JavaLand 2015Stateless authentication for microservices applications -  JavaLand 2015
Stateless authentication for microservices applications - JavaLand 2015
 
Stateless authentication for microservices
Stateless authentication for microservicesStateless authentication for microservices
Stateless authentication for microservices
 

Recently uploaded

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Recently uploaded (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016

  • 1. Efficient HTTP applications on the JVM with Ratpack Álvaro Sánchez-Mariscal Software Engineer, Grails committer Object Computing, Inc Platinum Sponsor #VoxxedBerlin @alvaro_sanchez
  • 2. Álvaro Sánchez-Mariscal Software Engineer Grails Development Team @alvaro_sanchez sanchezmariscala@ociweb.com
  • 3.
  • 4. OCI is the new home of Grails More at ociweb.com/grails
  • 5. Agenda • Introduction. • The handlers chain. • The context. • Ratpack modules. • Asynchronous & Non Blocking model. • Q&A.
  • 7. Slides, code & workshop • Slides: • http://bit.ly/ratpack-101-slides • Companion code: • http://bit.ly/ratpack-101-code • Workshop: • http://bit.ly/ratpack-101-workshop
  • 8. Before we start • Raise your hand if you have used: • Java. • Groovy. • Spock. • Ratpack?
  • 9. Introduction • Ratpack is: • A set of Java 8 libraries… • … lightweight, un-opinionated, Netty-based... • … for writing non-blocking HTTP applications… • … focused on performance and efficiency… • … with an emphasis on testability.. • … embracing Java 8 or Groovy as programming languages.
  • 10. When to use Ratpack? • For microservices. • For high performance applications. • For lightweight services (no container, batteries included).
  • 11. If you are writing microservices, why do you use macroframeworks?
  • 12. Ratpack is developer friendly • Starts up in milliseconds. • Development-time reloading (in ms) with Gradle. • First-class support for functional testing.
  • 13. Demo 1. Groovy script. 2. Gradle build with Lazybones.
  • 15. Handlers • An incoming request is passed through the handler chain. • A handler can: • Respond to the request. • Delegate to the next handler in the chain. • Insert more handlers in the chain and delegate to them.
  • 16. Handlers • Each handler is given a Context instance. • To interact with the request / response objects. • To access the registry. • Etc. • Note that Ratpack is not based on the Servlet API.
  • 19. The Context • The Context provides: • Access to the HTTP Request and Response objects. • Interaction with other handlers through next() and insert() methods. • Access to objects in the registry.
  • 20. The registry • The context is also a Registry of objects. • Handlers can store objects into the registry for use by downstream handlers.
  • 21. Demo 4. Working with the context.
  • 23. Ratpack modules • Ratpack can integrate with Google Guice for: • Dependency injection for services, etc. • Officially supported modules. • Reusing your own components as your modules.
  • 24. Official modules • Benchmarks (JMH). • Metrics (Dropwizard). • H2 Database. • Handlebars. • HikariCP JDBC pool. • Hystrix. • New Relic. • Pac4J. • RxJava. • HTTP sessions. • Spring Boot. • Thymeleaf.
  • 25. Demo 5. Using Guice and Jackson in Ratpack.
  • 27. The classic approach • A thread-per-request. • There is a relatively large thread pool. • Each request is assigned a thread from the pool. • If the request handling code performs blocking I/O, the thread sleeps until the result is received. • Overhead: thread management, memory consumption.
  • 28. Ratpack’s value proposition • HTTP IO is event-driven (non blocking). • Powered by Netty. • Handler chain is organised as a pipeline of asynchronous functions. • Small compute thread pool. • Blocking operations are executed in a separate pool. • Integration with existing libraries like RxJava.
  • 29. Async model • Ratpack guarantees a deterministic flow. • Promises are executed in the order they are defined. • Once the promises are resolved, they are executed in compute threads. • Async functions can be composed. • To avoid the callback hell.
  • 31. Álvaro Sánchez-Mariscal Software Engineer Grails Development Team @alvaro_sanchez sanchezmariscala@ociweb.com Danke!