SlideShare a Scribd company logo
Efficient HTTP
applications on the JVM
with Ratpack
Álvaro Sánchez-Mariscal
Application Architect - 4finance IT
@alvaro_sanchez
About me
● Passionate Software Developer.
○ Living in Madrid, Spain.
● Working professionally in Java since 2001.
○ BEA Systems, Sun Microsystems.
○ Groovy fanboy since 2007.
● Open source contributor: Grails, Ratpack, ..
● Speaker at JavaZone, GeeCON, JavaLand,
Codemotion...
@alvaro_sanchez
About
● We build:
● Consumer loan systems.
● Lending platform.
● Payment systems.
● Personal budgeting.
● Anti-fraud and risk system.
● We use:
● Spring Boot.
● Gradle.
● Java 8.
● Groovy.
● Jenkins, Ansible, ...
● We hire the best talent:
● In Warsaw, Prague, Riga, Vilnius and London.
● At http://www.4financeit.com.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Slides, code and workshop
available
• Slides:
• http://bit.ly/ratpack-101-slides
• Companion code:
• http://bit.ly/ratpack-101-code
• Workshop:
• http://bit.ly/ratpack-101-workshop
@alvaro_sanchez
More Ratpack in JDD
• 14:00, track 3
@alvaro_sanchez
Before we start
● Raise your hand if you know:
○ Java.
○ Groovy.
○ Spock.
○ Ratpack?
@alvaro_sanchez
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.
@alvaro_sanchez
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?
@alvaro_sanchez
Ratpack is developer friendly
• Starts up in milliseconds.
• Development-time reloading (in ms)
with Gradle.
• First-class support for functional
testing.
@alvaro_sanchez
Demo
1. Groovy script.
2. Gradle build with Lazybones.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
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.
@alvaro_sanchez
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.
@alvaro_sanchez
Demo
3. Handlers.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
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.
@alvaro_sanchez
The registry
● The context is also a Registry of
objects.
● Handlers can store objects into the
context for use by downstream handlers.
@alvaro_sanchez
Demo
4. Working with the context.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
Ratpack modules
● Ratpack can integrate with Google Guice
for:
○ Dependency injection for services, etc.
○ Officially supported modules.
○ Reusing your own components as your
modules.
@alvaro_sanchez
Official modules (1/2)
• Benchmarks (JMH).
• Metrics.
• H2 Database.
• Handlebars.
• HikariCP JDBC pool.
• Hystrix.
• Jackson.
• New Relic.
• Pac4J.
• Reactor.
• Groovy Remote
Control.
@alvaro_sanchez
Official modules (2/2)
• RxJava.
• HTTP Sessions.
• Spring Boot.
• Thymeleaf.
@alvaro_sanchez
Demo
5. Using Guice and the Jackson module.
@alvaro_sanchez
Agenda
● Introduction.
● The handlers chain.
● The context.
● Ratpack modules.
● Asynchronous & Non Blocking model.
● Q&A.
@alvaro_sanchez
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.
@alvaro_sanchez
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.
@alvaro_sanchez
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.
@alvaro_sanchez
Demo
6. Asynchronous model.
Dzięki!Álvaro Sánchez-Mariscal
Application Architect - 4finance IT
Images courtesy of

More Related Content

PDF
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
PDF
Intro to Ratpack (CDJDN 2015-01-22)
PDF
Ratpack Web Framework
PDF
Ratpack Web Framework
PPTX
Building Web Apps in Ratpack
PDF
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
PDF
Putting the Spark into Functional Fashion Tech Analystics
PDF
SGCE 2015 REST APIs
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Intro to Ratpack (CDJDN 2015-01-22)
Ratpack Web Framework
Ratpack Web Framework
Building Web Apps in Ratpack
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Putting the Spark into Functional Fashion Tech Analystics
SGCE 2015 REST APIs

What's hot (19)

PDF
Apache ManifoldCF @ Linux Day 2012
PDF
Geb Best Practices
PDF
CNCF opa
PPTX
Super Size Your Search
PPTX
Etl engine testing with scala
PDF
Gr8Conf 2016 - GORM Inside and Out
PPTX
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
PDF
Control and monitor_microservices_with_microprofile
PDF
Transactions in micro-services (fall 2019)
PDF
Gr8Conf 2016 - What's new in Grails 3
PPTX
PPTX
Rx Java architecture
PDF
NoSQL design pitfalls with Java
PDF
2015 Java update and roadmap, JUG sevilla
PDF
SOA Latam 2015
PDF
Fine-grained Authorization in a Containerized World
ODP
Nagios Conference 2014 - Luke Groschen - Using Nagios Network Analyzer and NS...
PDF
AIRflow at Scale
PDF
Scala Frameworks for Web Application 2016
Apache ManifoldCF @ Linux Day 2012
Geb Best Practices
CNCF opa
Super Size Your Search
Etl engine testing with scala
Gr8Conf 2016 - GORM Inside and Out
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Control and monitor_microservices_with_microprofile
Transactions in micro-services (fall 2019)
Gr8Conf 2016 - What's new in Grails 3
Rx Java architecture
NoSQL design pitfalls with Java
2015 Java update and roadmap, JUG sevilla
SOA Latam 2015
Fine-grained Authorization in a Containerized World
Nagios Conference 2014 - Luke Groschen - Using Nagios Network Analyzer and NS...
AIRflow at Scale
Scala Frameworks for Web Application 2016
Ad

Similar to Efficient HTTP applications on the JVM with Ratpack - JDD 2015 (20)

PDF
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
PDF
Ratpack 101 - GeeCON 2015
PDF
Ratpack 101 - GR8Conf 2015
PDF
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
ODP
Java concurrency
PPTX
AngularJS workshop for beginners.
PPTX
It new2015
PPTX
Evolve with laravel
PDF
Best practices for JavaScript RIAs
PDF
Introduction of React.js
PPTX
Your journey into the serverless world
PDF
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
PPTX
Data Science Salon: A Journey of Deploying a Data Science Engine to Production
PDF
Building Fullstack Serverless GraphQL APIs In The Cloud
PDF
How fast can you onboard a new team member with VAGRANT ?
PPTX
SELF - Becoming a Rails Developer - The Rest of the Story
PDF
Laravel vs. node.js war for the backend
ODP
JavaFX in Action Part I
PDF
JSFest 2019: Technology agnostic microservices at SPA frontend
PPTX
Why Concurrency is hard ?
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
Ratpack 101 - GeeCON 2015
Ratpack 101 - GR8Conf 2015
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
Java concurrency
AngularJS workshop for beginners.
It new2015
Evolve with laravel
Best practices for JavaScript RIAs
Introduction of React.js
Your journey into the serverless world
PHP At 5000 Requests Per Second: Hootsuite’s Scaling Story
Data Science Salon: A Journey of Deploying a Data Science Engine to Production
Building Fullstack Serverless GraphQL APIs In The Cloud
How fast can you onboard a new team member with VAGRANT ?
SELF - Becoming a Rails Developer - The Rest of the Story
Laravel vs. node.js war for the backend
JavaFX in Action Part I
JSFest 2019: Technology agnostic microservices at SPA frontend
Why Concurrency is hard ?
Ad

More from Alvaro Sanchez-Mariscal (20)

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

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
history of c programming in notes for students .pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Introduction to Artificial Intelligence
PDF
top salesforce developer skills in 2025.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Digital Strategies for Manufacturing Companies
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms I-SECS-1021-03
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Computer Software and OS of computer science of grade 11.pptx
Softaken Excel to vCard Converter Software.pdf
Designing Intelligence for the Shop Floor.pdf
history of c programming in notes for students .pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
wealthsignaloriginal-com-DS-text-... (1).pdf
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Introduction to Artificial Intelligence
top salesforce developer skills in 2025.pdf
Transform Your Business with a Software ERP System
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Digital Strategies for Manufacturing Companies
PTS Company Brochure 2025 (1).pdf.......
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Operating system designcfffgfgggggggvggggggggg
Which alternative to Crystal Reports is best for small or large businesses.pdf

Efficient HTTP applications on the JVM with Ratpack - JDD 2015