SlideShare a Scribd company logo
Ratpack and Grails 3 
by Lari Hotari @lhotari 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Ratpack and Spring Boot 
by Lari Hotari @lhotari 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Agenda 
• Grails 3 and Ratpack - Why 
• Why async? 
• Modularity and micro service architectures 
3
Grails 3 
• Build on Spring Boot 
• Embrace Gradle 
• Abstract packaging / deployment 
• Reach outside the servlet container 
• App profiles: Netty, Servlet, Batch, Hadoop 
• Deployment with runnable JARs 
• Support micro services, remove bloat, reduce 
dependencies 
4
5
6
Why Netty / Ratpack? 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. 
Why async?
What is application performance about? 
• Latency of operations 
• Throughput of operations 
• Quality of operations - efficiency, usability, 
responsiveness, correctness, consistency, integrity, 
reliability, availability, resilience, robustness, 
recoverability, security, safety, maintainability 
8
Amdahl's law 
9
Little's law 
L = λW 
MeanNumberInSystem = MeanThroughput * MeanResponseTime 
10 
→ 
MeanThroughput = MeanNumberInSystem / MeanResponseTime
Cons of the thread-per-request model in the light of Little's law and 
Amdahl's law 
• From Little's law: MeanNumberInSystem = 
MeanThroughput * MeanResponseTime 
• In the thread-per-request model, the upper bound for 
MeanNumberInSystem is the maximum for the number of 
request handling threads. This might limit the throughput of 
the system, especially when the response time get higher 
or request handling threads get blocked and hang. 
• Shared locks and resources might set the upper bound to 
a very low value. Such problems get worse under error 
conditions. 
11
Advantages of thread-per-request model 
• We are used to debugging the thread-per-request model 
- adding breakpoints, attaching the debugger and going 
through the stack 
• The synchronous blocking procedural programming 
model is something that programmers are used to doing. 
• There is friction in switching to different programming 
models and paradigms. 
12
Declarative Programming model 
• Declarative programming expresses the logic of a 
computation without describing its control flow. 
• It's programming without the call stack, the 
programmer doesn't decide execution details. 
• Examples: functional and reactive programming, event 
/ message based execution, distributed parallel 
computation algorithms like Map/Reduce 
13
KillerApp for non-blocking async model 
• Responsive streaming of a high number of clients on a 
single box 
• continuously connected real-time apps where low-latency 
and high availablity is a requirement 
• limited resources (must be efficient/optimal) 
• Follow Pivotal's https://github.com/reactor/reactor 
project that provides a Reactive Streams 
(http://www.reactive-streams.org/) implementation 14
Hello world in Ratpack 
15 
1 import static ratpack.groovy.Groovy.ratpack 
2 
3 ratpack { 
4 handlers { 
5 get { 
6 render "Hello world" 
7 } 
8 } 
9 } 
https://github.com/lhotari/hello-ratpack/blob/master/src/ratpack/Ratpack.groovy
Ratpack applications 
• Ratpacks comes with Guice for dependency injection 
• Guice modules are also used as the plugin system for Ratpack 
• not actual "plugins" in a technical sense since there isn't a 
plugin API and the developer takes care of wiring modules to 
Ratpack applications. 
• Examples of Ratpack module contributions: 
• Integrations to RxJava and Reactor. Can be used for async 
composition and preventing "callback hell". 
• Integration to Netflix Hystrix for adding error resilience 
functionality . f.e., Circuit-breaker pattern impl. 16
Demo 
• https://github.com/lhotari/ratpack-gorm-example 
• Spring Boot embedded in Ratpack, running GORM 
• Uses Ratpack Spring Boot support (0.9.9-SNAPSHOT) 
• Grails 3 builds on Spring Boot 
17
Modularity and Microservices 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Modularity 
• logical partitioning of the "software design" 
• allows complex software to be manageable for the 
purpose of implementation and maintenance 
19
Coupling and Cohesion 
• Coupling and cohesion are measures for describing how 
easy it will be to change the behaviour of some element 
in a system 
• Modules are coupled if a change in one forces a change 
in a the other 
• A module's cohesion is a measure of whether it's 
responsibilities form a meaningful unit 
source: GOOS book 20
Optimal coupling and cohesion 
• Low coupling between modules ⟹ easier to change 
• High cohesion within module ⟹ single responsibility 
21
Microservice definition by James Lewis 
• Each application only does one thing 
• Small enough to fit in your head 
• Small enough that you can throw them away 
• Embedded web container 
• Packaged as a single executable jar 
• Use HTTP and HATEOAS to decouple services 
• Each app exposes metrics about itself 
22
Polyglot persistence 
• Common principle is that each service owns it's data - 
there is no shared database across multiple services. 
• If this principle is followed, it usually means switching to 
Hexagonal architecture, where persistence is an 
integration and not part of the core. 
• "Start with the events and behaviour instead of the 
database." 
• Data consistency models in distributed systems 
23
Brooks: "No silver bullet" 
• Essential complexity 
• complexity that you cannot escape 
• Accidental complexity 
• we could be adding complexity by bad design 
24
Modular applications 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Monoliths in systems-of-systems 
26 
μser 
vice 
A 
Single 
Page App 
in 
Browser 
API 
Gateway 
service 
SAAS 
Service A 
SAAS 
Service B 
μser 
vice 
B 
μser 
vice 
C 
μser 
vice 
D 
μser 
vice 
E 
μser 
vice 
F
Modular monoliths 
• Modular monoliths are composed of loosely coupled 
modules of single responsibility 
• Enabling the 3rd way (after monoliths and 
microservices) for building applications on the JVM 
across different libraries and frameworks 
• Modules can be turned into true micro services when 
needed - instead of introducing accidental complexity to 
projects that don't really require micro services in the 
beginning, but could benefit of them later 27
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. 
Questions?
Thanks! 
Lari Hotari @lhotari 
Pivotal Software, Inc. 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.

More Related Content

PPTX
Ratpack and Grails 3 GR8Conf US 2014
PPTX
Performance tuning Grails Applications GR8Conf US 2014
PDF
Ratpack and Grails 3
PDF
Full Stack Reactive In Practice
PDF
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
PDF
The Evolution of Distributed Systems on Kubernetes
PPTX
Lessons From HPE: From Batch To Streaming For 20 Billion Sensors With Lightbe...
PDF
Pivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan
Ratpack and Grails 3 GR8Conf US 2014
Performance tuning Grails Applications GR8Conf US 2014
Ratpack and Grails 3
Full Stack Reactive In Practice
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
The Evolution of Distributed Systems on Kubernetes
Lessons From HPE: From Batch To Streaming For 20 Billion Sensors With Lightbe...
Pivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan

What's hot (18)

PDF
Digital Transformation with Kubernetes, Containers, and Microservices
PDF
Microservice message routing on Kubernetes
PDF
Nine Neins - where Java EE will never take you
PDF
Monitoring Big Data Systems Done "The Simple Way" - Demi Ben-Ari - Codemotion...
PDF
What next after microservices
PDF
Dual write strategies for microservices
PPTX
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
PDF
Microservices, Monoliths, SOA and How We Got Here
PDF
Cloudstate - Towards Stateful Serverless
PPTX
Real-Time Design Patterns
PPTX
Hands-on Performance Tuning Lab - Devoxx Poland
PDF
What’s New with Flowable?
PDF
Modernization patterns to refactor a legacy application into event driven mic...
PDF
Detecting Real-Time Financial Fraud with Cloudflow on Kubernetes
PDF
Revitalizing Aging Architectures with Microservices
PDF
MongoDB and Machine Learning with Flowable
PPTX
Kafka Summit NYC 2017 - Apache Kafka in the Enterprise: What if it Fails?
PDF
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
Digital Transformation with Kubernetes, Containers, and Microservices
Microservice message routing on Kubernetes
Nine Neins - where Java EE will never take you
Monitoring Big Data Systems Done "The Simple Way" - Demi Ben-Ari - Codemotion...
What next after microservices
Dual write strategies for microservices
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Microservices, Monoliths, SOA and How We Got Here
Cloudstate - Towards Stateful Serverless
Real-Time Design Patterns
Hands-on Performance Tuning Lab - Devoxx Poland
What’s New with Flowable?
Modernization patterns to refactor a legacy application into event driven mic...
Detecting Real-Time Financial Fraud with Cloudflow on Kubernetes
Revitalizing Aging Architectures with Microservices
MongoDB and Machine Learning with Flowable
Kafka Summit NYC 2017 - Apache Kafka in the Enterprise: What if it Fails?
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
Ad

Similar to Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014 (20)

PPTX
Reactive applications tools of the trade huff po
PDF
Ratpack and Grails 3
PPTX
Performance tuning Grails applications SpringOne 2GX 2014
PPTX
Unit No. II Architecture.pptx Cloud Microservices & Application
PDF
'How to build efficient backend based on microservice architecture' by Anton ...
ODP
Twelve Factor App With Lagom
PPTX
MuleSoft Meetup Adelaide 7th April 2021
PPTX
Twelve-Factor application pattern with Spring Framework
PPTX
Application Architecture for Cloud Computing
PPTX
Best practices for application migration to public clouds interop presentation
PDF
Stateful on Stateless - The Future of Applications in the Cloud
PDF
672065957-W13-CLO4-Portability-and-Interoperability.pdf
PDF
[WSO2Con Asia 2018] Architecting for Container-native Environments
PPTX
Building Cloud Ready Apps
PPTX
10 Key Steps for Moving from Legacy Infrastructure to the Cloud
PDF
Adopting the Cloud
PPTX
Technology insights: Decision Science Platform
PDF
Comparison of Current Service Mesh Architectures
PPTX
Microservices: Yes or not?
PDF
Study Notes - Using an API Gateway
Reactive applications tools of the trade huff po
Ratpack and Grails 3
Performance tuning Grails applications SpringOne 2GX 2014
Unit No. II Architecture.pptx Cloud Microservices & Application
'How to build efficient backend based on microservice architecture' by Anton ...
Twelve Factor App With Lagom
MuleSoft Meetup Adelaide 7th April 2021
Twelve-Factor application pattern with Spring Framework
Application Architecture for Cloud Computing
Best practices for application migration to public clouds interop presentation
Stateful on Stateless - The Future of Applications in the Cloud
672065957-W13-CLO4-Portability-and-Interoperability.pdf
[WSO2Con Asia 2018] Architecting for Container-native Environments
Building Cloud Ready Apps
10 Key Steps for Moving from Legacy Infrastructure to the Cloud
Adopting the Cloud
Technology insights: Decision Science Platform
Comparison of Current Service Mesh Architectures
Microservices: Yes or not?
Study Notes - Using an API Gateway
Ad

Recently uploaded (20)

PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
ai tools demonstartion for schools and inter college
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administration Chapter 2
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
ISO 45001 Occupational Health and Safety Management System
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How to Choose the Right IT Partner for Your Business in Malaysia
ai tools demonstartion for schools and inter college
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
history of c programming in notes for students .pptx
System and Network Administration Chapter 2
Odoo POS Development Services by CandidRoot Solutions
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms I-SECS-1021-03
Online Work Permit System for Fast Permit Processing
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo Companies in India – Driving Business Transformation.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Introduction to Artificial Intelligence
Design an Analysis of Algorithms II-SECS-1021-03
Which alternative to Crystal Reports is best for small or large businesses.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Upgrade and Innovation Strategies for SAP ERP Customers

Ratpack and Grails 3 (and Spring Boot) SpringOne 2GX 2014

  • 1. Ratpack and Grails 3 by Lari Hotari @lhotari © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 2. Ratpack and Spring Boot by Lari Hotari @lhotari © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 3. Agenda • Grails 3 and Ratpack - Why • Why async? • Modularity and micro service architectures 3
  • 4. Grails 3 • Build on Spring Boot • Embrace Gradle • Abstract packaging / deployment • Reach outside the servlet container • App profiles: Netty, Servlet, Batch, Hadoop • Deployment with runnable JARs • Support micro services, remove bloat, reduce dependencies 4
  • 5. 5
  • 6. 6
  • 7. Why Netty / Ratpack? © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. Why async?
  • 8. What is application performance about? • Latency of operations • Throughput of operations • Quality of operations - efficiency, usability, responsiveness, correctness, consistency, integrity, reliability, availability, resilience, robustness, recoverability, security, safety, maintainability 8
  • 10. Little's law L = λW MeanNumberInSystem = MeanThroughput * MeanResponseTime 10 → MeanThroughput = MeanNumberInSystem / MeanResponseTime
  • 11. Cons of the thread-per-request model in the light of Little's law and Amdahl's law • From Little's law: MeanNumberInSystem = MeanThroughput * MeanResponseTime • In the thread-per-request model, the upper bound for MeanNumberInSystem is the maximum for the number of request handling threads. This might limit the throughput of the system, especially when the response time get higher or request handling threads get blocked and hang. • Shared locks and resources might set the upper bound to a very low value. Such problems get worse under error conditions. 11
  • 12. Advantages of thread-per-request model • We are used to debugging the thread-per-request model - adding breakpoints, attaching the debugger and going through the stack • The synchronous blocking procedural programming model is something that programmers are used to doing. • There is friction in switching to different programming models and paradigms. 12
  • 13. Declarative Programming model • Declarative programming expresses the logic of a computation without describing its control flow. • It's programming without the call stack, the programmer doesn't decide execution details. • Examples: functional and reactive programming, event / message based execution, distributed parallel computation algorithms like Map/Reduce 13
  • 14. KillerApp for non-blocking async model • Responsive streaming of a high number of clients on a single box • continuously connected real-time apps where low-latency and high availablity is a requirement • limited resources (must be efficient/optimal) • Follow Pivotal's https://github.com/reactor/reactor project that provides a Reactive Streams (http://www.reactive-streams.org/) implementation 14
  • 15. Hello world in Ratpack 15 1 import static ratpack.groovy.Groovy.ratpack 2 3 ratpack { 4 handlers { 5 get { 6 render "Hello world" 7 } 8 } 9 } https://github.com/lhotari/hello-ratpack/blob/master/src/ratpack/Ratpack.groovy
  • 16. Ratpack applications • Ratpacks comes with Guice for dependency injection • Guice modules are also used as the plugin system for Ratpack • not actual "plugins" in a technical sense since there isn't a plugin API and the developer takes care of wiring modules to Ratpack applications. • Examples of Ratpack module contributions: • Integrations to RxJava and Reactor. Can be used for async composition and preventing "callback hell". • Integration to Netflix Hystrix for adding error resilience functionality . f.e., Circuit-breaker pattern impl. 16
  • 17. Demo • https://github.com/lhotari/ratpack-gorm-example • Spring Boot embedded in Ratpack, running GORM • Uses Ratpack Spring Boot support (0.9.9-SNAPSHOT) • Grails 3 builds on Spring Boot 17
  • 18. Modularity and Microservices © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 19. Modularity • logical partitioning of the "software design" • allows complex software to be manageable for the purpose of implementation and maintenance 19
  • 20. Coupling and Cohesion • Coupling and cohesion are measures for describing how easy it will be to change the behaviour of some element in a system • Modules are coupled if a change in one forces a change in a the other • A module's cohesion is a measure of whether it's responsibilities form a meaningful unit source: GOOS book 20
  • 21. Optimal coupling and cohesion • Low coupling between modules ⟹ easier to change • High cohesion within module ⟹ single responsibility 21
  • 22. Microservice definition by James Lewis • Each application only does one thing • Small enough to fit in your head • Small enough that you can throw them away • Embedded web container • Packaged as a single executable jar • Use HTTP and HATEOAS to decouple services • Each app exposes metrics about itself 22
  • 23. Polyglot persistence • Common principle is that each service owns it's data - there is no shared database across multiple services. • If this principle is followed, it usually means switching to Hexagonal architecture, where persistence is an integration and not part of the core. • "Start with the events and behaviour instead of the database." • Data consistency models in distributed systems 23
  • 24. Brooks: "No silver bullet" • Essential complexity • complexity that you cannot escape • Accidental complexity • we could be adding complexity by bad design 24
  • 25. Modular applications © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 26. Monoliths in systems-of-systems 26 μser vice A Single Page App in Browser API Gateway service SAAS Service A SAAS Service B μser vice B μser vice C μser vice D μser vice E μser vice F
  • 27. Modular monoliths • Modular monoliths are composed of loosely coupled modules of single responsibility • Enabling the 3rd way (after monoliths and microservices) for building applications on the JVM across different libraries and frameworks • Modules can be turned into true micro services when needed - instead of introducing accidental complexity to projects that don't really require micro services in the beginning, but could benefit of them later 27
  • 28. © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. Questions?
  • 29. Thanks! Lari Hotari @lhotari Pivotal Software, Inc. © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.

Editor's Notes

  • #9: Performance == Fast , Latency Performance == Efficiency , Throughput Performance == Correctness , Quality