SlideShare a Scribd company logo
HIGH PERFORMANCE MICROSERVICES WITH RATPACK AND SPRING BOOT
DAN WOODS
@DANVELOPER
SENIOR
SOFTWARE
ENGINEER
WORKING ON CLOUD &
DEVOPS TOOLING
O'REILLY
AUTHOR, 2016
LEARNING RATPACK
SUPPORT YOUR
COMMUNITY.ALL ROYALTIES FOR LEARNING RATPACK
GO DIRECTLY TO GR8LADIES
HTTP://GR8LADIES.ORG
ROUGH AGENDA
> Brief overview
> Execution model
> Registries
> Registries + Spring
> Microservice example
> Performance numbers
OVERVIEW
Ratpack is a high throughput, non-blocking, asynchronous,
reactive web framework for the JVM
Built on Java 8, has first class support Groovy
Realistically, works great with every JVM language
@Grab('io.ratpack:ratpack-groovy:1.4.0-rc-2')
import static ratpack.groovy.Groovy.ratpack
ratpack {
handlers {
get { render "Hello World!" }
}
}
package app;
import ratpack.server.RatpackServer
public class Main {
public static void main(String args[]) throws Exception {
RatpackServer.start(spec -> spec
.handlers(chain -> chain
.get(ctx -> ctx.render("Hello World!"))
)
);
}
}
No opinions about how you build your application
Make common things as easy as possible
Explicit, no convention-over-configuration
First class concerns: performance, developer experience,
packaging
EXECUTION
MODEL
Asynchronous programming is hard!
Traditionally there is a temporal disconnect between
calling an async function and getting its response.
public void asyncDbCall(Long productId, Consumer callback) {
Product product = ... async db call + future + wait for future
callback.apply(product);
}
Bad things happen!
final List products = new ArrayList();
Long productId = request.pathTokens.productId;
db.asyncDbCall(productId, product -> products.add(product));
Long nextProductId = productId+1;
db.asyncDbCall(nextProductId, product -> products.add(product));
response.send(products);
There is no guarantee as to what order async calls will
be executed!
final List products = new ArrayList();
String productId = request.pathTokens.productId;
db.asyncDbCall(productId, product -> products.add(product)); // call may return first, maybe not!
String nextProductId = productId+1;
db.asyncDbCall(nextProductId, product -> products.add(product)); // call may return second, may not!
response.send(products); // what even is the value of `products` here!
Luckily, Ratpack's execution model provides deterministic
processing of asynchronous calls
An Execution in Ratpack is the equivalent construct to
a continuation
Ratpack Promise type denotes a frame in the
continuation (a.k.a "execution segments")
High Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring Boot
Execution segments are guaranteed to execute in their
given order.
RATPACK MAINTAINS A SMALL THREAD
POOL FOR ALL ITS PROCESSING
(TYPICALLY 2 * NUM CPU CORES)
While an execution segment is processing, its thread is
able to handle other processing and requests
Ratpack ensures the resources given to your application
are being efficiently utilized
Ratpack's RxJava integration provides a scheduler that
fits Observable into the execution model
Provides an implementation of Reactive Streams, which
also fits into the execution model
REGISTRIES
Abstraction over dependency injection
Provides a basic component binding infrastructure
REGISTRIES ARE
EVERYWHERE IN
RATPACK
CAN BE BACKED BY ANY COMPONENT-
PROVIDING SYSTEM
SPRING BOOT AND GUICE NATIVELY SUPPORTED
Can quickly prototype without any DI system
public static void main(String[] args) throws Exception {
RatpackServer.start(spec -> spec
.registryOf(r -> r.add(new MyAsyncDbService())) // bind my service in the registry
.handlers(chain -> chain
.get(ctx -> {
MyAsyncDbService db = ctx.get(MyAsyncDbService.class); // retrieve it later
// ...
})
)
);
}
Integrate with Spring Boot when you're ready!
@SpringBootApplication // Spring Boot!!
public class Main {
@Bean
public MyAsyncDbService myAsyncDbService() { // bind it as a bean!
return new MyAsyncDbService();
}
public static void main(String[] args) {
// turn Spring Boot into a Ratpack registry!
Registry registry = ratpack.spring.Spring.spring(Main.class);
RatpackServer.start(spec -> spec
.registry(registry)
.handlers(chain -> chain
.get(ctx -> {
MyAsyncDbService db = ctx.get(MyAsyncDbService.class); // retrieve your service!
// ...
})
)
)
}
}
Architect your application using all the helpful aspects
of Spring Boot, while using Ratpack under the hood for
high throughput, reactive, async, non-blocking
processing
MICROSERVICE EXAMPLE
CODE: HTTPS://GITHUB.COM/DANVELOPER/S1P-HIGH-PERF-MICROSERVICES
PERFORMANCE
NUMBERS
A quick tirade about performance testing...
Generalizing performance numbers for all use cases is
impossible
The numbers provided should be used as a guide, not the
word of law
"YOU SHOULDN'T
TEST ON THE
CLOUD!!"
Unrealistic.
Modern performance testing needs to be about how much
burst traffic can be sustained, without your service
falling over, before you can horizontally scale it.
PERFORMANCE NUMBERS
HTTPS://GITHUB.COM/DANVELOPER/S1P-HIGH-PERF-MICROSERVICES/BLOB/MASTER/README.MD
FUTURE
POSSIBILITIES
Spring 5 will be all reactive; will be possible to
integrate Spring controllers into Ratpack
Provide a scheduler to Project Reactor so that Flex
and Mono types can utilize the execution model
Questions?

More Related Content

PDF
Ratpack Web Framework
PPTX
Building Web Apps in Ratpack
PDF
Groovy in the Cloud
PPT
Ratpack - Classy and Compact Groovy Web Apps
PPTX
Ratpack - SpringOne2GX 2015
PDF
Introducing spring
PPTX
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES HAS NEVER BEEN SO EASY
PDF
Using React with Grails 3
Ratpack Web Framework
Building Web Apps in Ratpack
Groovy in the Cloud
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - SpringOne2GX 2015
Introducing spring
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES HAS NEVER BEEN SO EASY
Using React with Grails 3

What's hot (20)

PDF
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
PDF
markedj: The best of markdown processor on JVM
PDF
Mastering Grails 3 Plugins - Greach 2016
PPTX
PDF
Introduction to gradle
PDF
Modern operations with Apache Sling (2014 adaptTo version)
PDF
Log monitoring with Logstash and Icinga
PDF
Gitlab ci, cncf.sk
PDF
Nebula: Netflix's OSS Gradle Plugins
PDF
Gitlab and Lingvokot
PDF
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
PDF
Netflix Nebula - Gradle Summit 2014
PDF
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES
ODP
Gradle: The Build System you have been waiting for!
PDF
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
PDF
Gitlab ci e kubernetes, build test and deploy your projects like a pro
PDF
SF Gradle Meetup - Netflix OSS
PPTX
Integration testing dropwizard
PDF
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
PDF
Gradle presentation
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
markedj: The best of markdown processor on JVM
Mastering Grails 3 Plugins - Greach 2016
Introduction to gradle
Modern operations with Apache Sling (2014 adaptTo version)
Log monitoring with Logstash and Icinga
Gitlab ci, cncf.sk
Nebula: Netflix's OSS Gradle Plugins
Gitlab and Lingvokot
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
Netflix Nebula - Gradle Summit 2014
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES
Gradle: The Build System you have been waiting for!
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Gitlab ci e kubernetes, build test and deploy your projects like a pro
SF Gradle Meetup - Netflix OSS
Integration testing dropwizard
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
Gradle presentation
Ad

Viewers also liked (17)

PDF
Forex AutoPilot
PDF
Ratpack and Grails 3
PDF
Zehn Jahre JPA – Architekturkonzepte und Best Practices revisited
PDF
Effiziente datenpersistierung mit JPA 2.1 und Hibernate
PPT
Usage concurrence in java
PPTX
Java threads - part 2
PPTX
Java threads - part 3
PPTX
Java threads - part 1
PPTX
Java 8. Thread pools
PPTX
Multithreading in java past and actual
PDF
Grails Plugin Best Practices
PPTX
Power of LinkedIn Lookup: finding hidden talent in your organization | Talent...
PDF
Mapping Human-Centric Product Vision (ProductCamp Boston 2016)
PPTX
2014 Qoppa Software PDF Solutions
PDF
Chemistry Connect
PPTX
Bianco toro
PDF
Analisis arquitectonico y estudio de medio geografico del sitio arqueologico ...
Forex AutoPilot
Ratpack and Grails 3
Zehn Jahre JPA – Architekturkonzepte und Best Practices revisited
Effiziente datenpersistierung mit JPA 2.1 und Hibernate
Usage concurrence in java
Java threads - part 2
Java threads - part 3
Java threads - part 1
Java 8. Thread pools
Multithreading in java past and actual
Grails Plugin Best Practices
Power of LinkedIn Lookup: finding hidden talent in your organization | Talent...
Mapping Human-Centric Product Vision (ProductCamp Boston 2016)
2014 Qoppa Software PDF Solutions
Chemistry Connect
Bianco toro
Analisis arquitectonico y estudio de medio geografico del sitio arqueologico ...
Ad

Similar to High Performance Microservices with Ratpack and Spring Boot (20)

PPTX
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
PDF
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
PDF
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
PDF
Ratpack 101 - GeeCON 2015
PDF
Intro to Ratpack (CDJDN 2015-01-22)
PDF
Ratpack the story so far
PDF
There's more to Ratpack than non-blocking
PDF
Ratpack Web Framework
PDF
Reactive All the Way Down the Stack
PDF
Ratpack and Grails 3
PDF
Microservices and the Art of Taming the Dependency Hell Monster
PPTX
Ratpack and Grails 3 GR8Conf US 2014
KEY
Spring in the Cloud - using Spring with Cloud Foundry
PDF
JVM Web Frameworks Exploration
PPTX
Spring boot Introduction
PDF
Microservices - opportunities, dilemmas and problems
PDF
The spring 32 update final
PDF
Ratpack JVM_MX Meetup February 2016
PPTX
Spring batch for large enterprises operations
PDF
Scaling Gilt: from Monolithic Ruby Application to Distributed Scala Micro-Ser...
Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014
JDD2015: In English Efficient HTTP applications on the JVM with Ratpack - Álv...
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
Ratpack 101 - GeeCON 2015
Intro to Ratpack (CDJDN 2015-01-22)
Ratpack the story so far
There's more to Ratpack than non-blocking
Ratpack Web Framework
Reactive All the Way Down the Stack
Ratpack and Grails 3
Microservices and the Art of Taming the Dependency Hell Monster
Ratpack and Grails 3 GR8Conf US 2014
Spring in the Cloud - using Spring with Cloud Foundry
JVM Web Frameworks Exploration
Spring boot Introduction
Microservices - opportunities, dilemmas and problems
The spring 32 update final
Ratpack JVM_MX Meetup February 2016
Spring batch for large enterprises operations
Scaling Gilt: from Monolithic Ruby Application to Distributed Scala Micro-Ser...

More from Daniel Woods (9)

PPTX
Continuous Delivery with Spinnaker and OpenStack
PPTX
Microservices: The Right Way
PDF
Facilitating Continuous Delivery at Scale
PDF
Continuous Delivery with NetflixOSS
PDF
Server-Side JavaScript with Nashorn
PDF
Future of Grails
PPTX
Groovy for System Administrators
PPTX
Message Driven Architecture in Grails
PDF
Gainesville Web Developer Group, Sept 2012
Continuous Delivery with Spinnaker and OpenStack
Microservices: The Right Way
Facilitating Continuous Delivery at Scale
Continuous Delivery with NetflixOSS
Server-Side JavaScript with Nashorn
Future of Grails
Groovy for System Administrators
Message Driven Architecture in Grails
Gainesville Web Developer Group, Sept 2012

Recently uploaded (20)

PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Transform Your Business with a Software ERP System
PPTX
Introduction to Artificial Intelligence
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
L1 - Introduction to python Backend.pptx
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
System and Network Administration Chapter 2
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Transform Your Business with a Software ERP System
Introduction to Artificial Intelligence
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
VVF-Customer-Presentation2025-Ver1.9.pptx
Operating system designcfffgfgggggggvggggggggg
L1 - Introduction to python Backend.pptx
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
System and Network Administration Chapter 2
ManageIQ - Sprint 268 Review - Slide Deck
Digital Strategies for Manufacturing Companies
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Online Work Permit System for Fast Permit Processing
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Navsoft: AI-Powered Business Solutions & Custom Software Development
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
Understanding Forklifts - TECH EHS Solution
Upgrade and Innovation Strategies for SAP ERP Customers
2025 Textile ERP Trends: SAP, Odoo & Oracle

High Performance Microservices with Ratpack and Spring Boot