SlideShare a Scribd company logo
1 of 27
Download to read offline
GRAILS MONOLITH TO MICROSERVICE TO FAAS
Created by /Michael Wyszinski @MikeWyszinski
ABOUT ME
Coding professionally since 1997...
Grails user/fan since 2009-ish
Principal Architect@WestconComstor
OVERVIEW
Why this topic?
Our Grails Application
Microservice & FaaS Architecture
FaaS Demo
Grails monolith -> Microservices
Grails monolith -> FaaS
Conclusion
OUR GRAILS "MONOLITH" - HISTORY
Started life in 2007 using proprietary javaspace based
architecture... In 2013, ported to grails 2.x over 6 months...
Java Groovy JavaScript
0
200k
400k
600k
loc ­ pre­Grails
loc ­ Grails
We were also able to leverage the grails ecosystem: GORM,
shiro plugin, audit plugin, dbmigration etc..
Our Team ♥'s Grails!
OUR GRAILS "MONOLITH" - FEATURES
SaaS, cloud service brokerage
Quote, Order, Manage, Bill many cloud products via a
single application
Global tenant base
Tenants are: internal users, resellers, vendors, end-
customers
Custom code per tenant
OUR GRAILS "MONOLITH" - COMPONENTS
Component Description Artefact
core shared "core": 67 domain classes, 66 services, multi-
tenancy plugin, audit plugin, etc
JAR
api REST API WAR
backend runs async jobs (order processing & provisioning, etc)
triggered by rabbitMQ messages
WAR
shell run custom shell scripts manually/cron N/A
portal angularjs portal for all users/tenants TAR
admin-ui semi auto-generated grails MVC app for internal power
users(to be decommisioned)
WAR
WHAT ARE MICROSERVICES?
“In short, the microservice architectural style
[1] is an approach to developing a single
application as a suite of small services, each
running in its own process and
communicating with lightweight mechanisms,
often an HTTP resource API. These services
are built around business capabilities and
independently deployable by fully automated
deployment machinery.”
- martinfowler.com
DEVELOPING MICROSERVICES
scaling unit: per μ-service
concurrency: developer de ned
deployment: developer de ned
infrastructure: devops managed
WHAT IS SERVERLESS/FAAS?
“Serverless can also mean applications where some
amount of server-side logic is still written by the
application developer but unlike traditional architectures
is run in stateless compute containers that are event-
triggered, ephemeral (may only last for one invocation),
and fully managed by a 3rd party.
One way to think of this is ‘Functions as a service / FaaS”
- martinfowler.com
servers DO exist. ...However, they are not accessible to
developers, hence "serverless"
IAAS/CAAS/PAAS/FAAS
Source - https://www.voxxed.com/blog/2016/12/serverless-faas-aws-lambda-java/
ALL FAAS PLATFORMS...
...implement smallest possible μ-service -> f(x) = y
...are event-driven (platform speci c events)
...have an HTTP API event trigger
...support multiple f(x) runtimes (jvm, python, nodejs, c#, go,
etc)
...disposable runtime env instanciated per f(x) invocation
...runtime env resources (RAM/CPU) con gurable per f(x)
FAAS PROVIDERS
ONLY HOSTED
Amazon AWS Lambda
Microsoft Azure Functions
Google Cloud Functions
+ many others...
OPEN SOURCE
IBM OpenWhisk
https://funktion.fabric8.io/
https://github.com/b rsh/serverless-docker + more all the
time...
FAAS HELLOWORLD DEMO!
HELLOWORLD - BUILD
apply plugin: 'java'
apply plugin: 'groovy'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile (
'org.codehaus.groovy:groovy-all:2.4.7',
'com.amazonaws:aws-lambda-java-core:1.1.0',
'com.amazonaws:aws-lambda-java-log4j:1.0.0',
'com.fasterxml.jackson.core:jackson-core:2.8.5',
'com.fasterxml.jackson.core:jackson-databind:2.8.5',
HELLOWORLD - CONFIG
service: groovy-hello
provider:
name: aws
runtime: java8
memorySize: 512
cfLogs: true
package:
artifact: build/distributions/hello.zip
functions:
hello:
handler: com.serverless.HelloWorldHandler
events:
- http:
path: helloworld
HELLOWORLD - HANDLER
package com.helloworld
class HelloWorldHandler implements RequestHandler<Map<String, Object>, ApiGateway
@Override
public ApiGatewayResponse handleRequest(Map<String, Object> input, Contex
LOG.info("received: " + input);
//Process the request
Response responseBody = new Response("HelloWorld!", input);
return ApiGatewayResponse.builder()
.setStatusCode(200)
.setObjectBody(responseBody)
.build();
}
}
DEVELOPING FAAS
scaling unit: f(x)
concurrency: f(x), "in nite" *
deployment: f(x)
infrastructure: platform provided
FAAS CAVEATS
Latency: Cold start times
Hosted Limits: deployed code size, execution time limits,
concurrent invocs, etc
EXAMPLE LIMITS - AWS LAMBDA
FAAS COSTS
Traf c Patterns Determines "Raw" savings
Ef ciency Gains; Maintenance & Ops not re ected in Bill
"in nite" scale! in nitly large bill during DDOS?
SERVERLESSCALC.COM
Calculating cost for AWS Lambda, Azure
Functions, Google Cloud Functions, and IBM
OpenWhisk
Number of Executions
Estimated Execution Time (ms)
Serverless Cost
Calculator (beta)
Serverless Cost
Calculator
Peter Sbarski and
the A Cloud Guru
Team.
Grab our book
Number
of
Executions

© Peter Sbarski (A Cloud Guru)
Design: HTML5 UP
  
GRAILS MONOLITH -> MICROSERVICE
1. refactor: shared domain + api + backend projects into...
N-deployable artefacts along business functions
(OrderService, QuoteService, etc)
Artefacts could contain both REST & async jobs
2. that's pretty much it...
3. plugins? shared domains? versioning eveything..
GRAILS MONOLITH -> FAAS
grails create-app my-faas --profile rest-api
cd my-faas
grails create-domain-class foo
grails grails generate-all my.faas.Foo
grails prod war
ls -lh build/libs/hello-faas-0.1.war
-rw-r--r-- 1 mike staff 60M Jan 2 00:23 build/libs/hello-faas-0.1.war
1. Remove dependencies to shrink lib < 50MB
2. no tomcat...
3. found mock! https://github.com/bleshik/aws-lambda-servlet
4. refactor to mock servlet container
wait. does grails behavior depend on servlet lifecycle?
grails application context?
do plugins I'm using depend on servlet lifecycle?
5. felt like a lot of more investigation required...
TAKEAWAY
FaaS now provides functionality that overlaps with Grails
(and prob most frameworks...)
Tomcat replaced by API gateway ✘
API gateways provide caching, SSL term, auth, SSO, etc...
Not trivial to port Grails(and prob most frameworks) to
FaaS
INTERESTING FAAS FEATURES
Isolated runtime env -> f(x) dont compete for shared
heap/cpu
Concurrency, programming model can be single threaded...
..but, shared resources (DBs,etc) still need to handle
concurrent load
async io?
Disposable runtime env -> run untrusted code
FINAL REMARKS
Grails Monolith to Microservices? :-)
Grails Monolith to FaaS? Prob Not Impossible.
Grails Still rocks ;-)
“ 1. Almost all the successful microservice
stories have started with a monolith that got
too big and was broken up
2. Almost all the cases where I've heard of a
system that was built as a microservice
system from scratch, it has ended up in serious
trouble. ”
- martinfowler.com
THANKS

More Related Content

What's hot

Hybris install telco accelerators on aws-ec2
Hybris   install telco accelerators on aws-ec2Hybris   install telco accelerators on aws-ec2
Hybris install telco accelerators on aws-ec2Venugopal Gummadala
 
Continuous Delivery & Integration with JBoss Fuse on Openshift
Continuous Delivery & Integration with JBoss Fuse on OpenshiftContinuous Delivery & Integration with JBoss Fuse on Openshift
Continuous Delivery & Integration with JBoss Fuse on OpenshiftCharles Moulliard
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud FoundryAndy Piper
 
Spring Cloud Into Production
Spring Cloud Into ProductionSpring Cloud Into Production
Spring Cloud Into ProductionTodd Miller
 
"[WORKSHOP] K8S for developers", Denis Romanuk
"[WORKSHOP] K8S for developers", Denis Romanuk"[WORKSHOP] K8S for developers", Denis Romanuk
"[WORKSHOP] K8S for developers", Denis RomanukFwdays
 
DevOps Toolbox: Infrastructure as code
DevOps Toolbox: Infrastructure as codeDevOps Toolbox: Infrastructure as code
DevOps Toolbox: Infrastructure as codesriram_rajan
 
Websockets: Pushing the web forward
Websockets: Pushing the web forwardWebsockets: Pushing the web forward
Websockets: Pushing the web forwardMark Roden
 
Apache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless ComputingApache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless ComputingUpkar Lidder
 
Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...
Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...
Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...VMware Tanzu
 
Jelastic - Containers Live Migration Behind the Scene
Jelastic - Containers Live Migration Behind the SceneJelastic - Containers Live Migration Behind the Scene
Jelastic - Containers Live Migration Behind the SceneJelastic Multi-Cloud PaaS
 
How to build an event-driven, polyglot serverless microservices framework on ...
How to build an event-driven, polyglot serverless microservices framework on ...How to build an event-driven, polyglot serverless microservices framework on ...
How to build an event-driven, polyglot serverless microservices framework on ...Animesh Singh
 
How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...
How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...
How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...Vietnam Open Infrastructure User Group
 
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)VMware Tanzu
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAmazon Web Services
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...Oleg Shalygin
 
Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for MicroservicesCloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for MicroservicesMatt Stine
 
Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1Hao H. Zhang
 
Sebastien goasguen cloud stack and docker
Sebastien goasguen   cloud stack and dockerSebastien goasguen   cloud stack and docker
Sebastien goasguen cloud stack and dockerShapeBlue
 
Sf bay area Kubernetes meetup dec8 2016 - deployment models
Sf bay area Kubernetes meetup dec8 2016 - deployment modelsSf bay area Kubernetes meetup dec8 2016 - deployment models
Sf bay area Kubernetes meetup dec8 2016 - deployment modelsPeter Ss
 

What's hot (20)

Hybris install telco accelerators on aws-ec2
Hybris   install telco accelerators on aws-ec2Hybris   install telco accelerators on aws-ec2
Hybris install telco accelerators on aws-ec2
 
Continuous Delivery & Integration with JBoss Fuse on Openshift
Continuous Delivery & Integration with JBoss Fuse on OpenshiftContinuous Delivery & Integration with JBoss Fuse on Openshift
Continuous Delivery & Integration with JBoss Fuse on Openshift
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud Foundry
 
Spring Cloud Into Production
Spring Cloud Into ProductionSpring Cloud Into Production
Spring Cloud Into Production
 
"[WORKSHOP] K8S for developers", Denis Romanuk
"[WORKSHOP] K8S for developers", Denis Romanuk"[WORKSHOP] K8S for developers", Denis Romanuk
"[WORKSHOP] K8S for developers", Denis Romanuk
 
DevOps Toolbox: Infrastructure as code
DevOps Toolbox: Infrastructure as codeDevOps Toolbox: Infrastructure as code
DevOps Toolbox: Infrastructure as code
 
Websockets: Pushing the web forward
Websockets: Pushing the web forwardWebsockets: Pushing the web forward
Websockets: Pushing the web forward
 
SRE & Kubernetes
SRE & KubernetesSRE & Kubernetes
SRE & Kubernetes
 
Apache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless ComputingApache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless Computing
 
Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...
Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...
Cloud Foundry and OpenStack - A Marriage Made in Heaven! (Cloud Foundry Summi...
 
Jelastic - Containers Live Migration Behind the Scene
Jelastic - Containers Live Migration Behind the SceneJelastic - Containers Live Migration Behind the Scene
Jelastic - Containers Live Migration Behind the Scene
 
How to build an event-driven, polyglot serverless microservices framework on ...
How to build an event-driven, polyglot serverless microservices framework on ...How to build an event-driven, polyglot serverless microservices framework on ...
How to build an event-driven, polyglot serverless microservices framework on ...
 
How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...
How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...
How we Upgraded Public Cloud From Juno to Queens with Minimal Downtime? | Ngu...
 
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for Government
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
 
Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for MicroservicesCloud Foundry Diego: Modular and Extensible Substructure for Microservices
Cloud Foundry Diego: Modular and Extensible Substructure for Microservices
 
Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1Kubernetes Architecture - beyond a black box - Part 1
Kubernetes Architecture - beyond a black box - Part 1
 
Sebastien goasguen cloud stack and docker
Sebastien goasguen   cloud stack and dockerSebastien goasguen   cloud stack and docker
Sebastien goasguen cloud stack and docker
 
Sf bay area Kubernetes meetup dec8 2016 - deployment models
Sf bay area Kubernetes meetup dec8 2016 - deployment modelsSf bay area Kubernetes meetup dec8 2016 - deployment models
Sf bay area Kubernetes meetup dec8 2016 - deployment models
 

Viewers also liked

Rest with grails 3
Rest with grails 3Rest with grails 3
Rest with grails 3Jenn Strater
 
Gilt from monolith ruby app to microservice scala service architecture
Gilt from monolith ruby app to microservice scala service architectureGilt from monolith ruby app to microservice scala service architecture
Gilt from monolith ruby app to microservice scala service architectureJonathan (Yoni) Goldberg
 
Taming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup HamburgTaming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup HamburgDennis Traub
 
An introduction to Microservices
An introduction to MicroservicesAn introduction to Microservices
An introduction to MicroservicesCisco DevNet
 
Spring IO '15 - Developing microservices, Spring Boot or Grails?
Spring IO '15 - Developing microservices, Spring Boot or Grails?Spring IO '15 - Developing microservices, Spring Boot or Grails?
Spring IO '15 - Developing microservices, Spring Boot or Grails?Fátima Casaú Pérez
 
Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015
Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015
Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015Teo Ruiz
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice ArchitectureRich Lee
 
Evolving toward Microservices - O’Reilly SACON Keynote
Evolving toward Microservices  - O’Reilly SACON KeynoteEvolving toward Microservices  - O’Reilly SACON Keynote
Evolving toward Microservices - O’Reilly SACON KeynoteChristopher Grant
 
Monolith to Microservices - O’Reilly Oscon
Monolith to Microservices - O’Reilly OsconMonolith to Microservices - O’Reilly Oscon
Monolith to Microservices - O’Reilly OsconChristopher Grant
 
Software Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based ArchitecturesSoftware Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based ArchitecturesAngelos Kapsimanis
 
From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015Randy Shoup
 
Pragmatic Microservices
Pragmatic MicroservicesPragmatic Microservices
Pragmatic MicroservicesRandy Shoup
 
Cloud Native Java Microservices
Cloud Native Java MicroservicesCloud Native Java Microservices
Cloud Native Java MicroservicesKenny Bastani
 
Serverless - When to FaaS?
Serverless - When to FaaS?Serverless - When to FaaS?
Serverless - When to FaaS?Benny Bauer
 

Viewers also liked (16)

Rest with grails 3
Rest with grails 3Rest with grails 3
Rest with grails 3
 
Gilt from monolith ruby app to microservice scala service architecture
Gilt from monolith ruby app to microservice scala service architectureGilt from monolith ruby app to microservice scala service architecture
Gilt from monolith ruby app to microservice scala service architecture
 
Final_Presentation
Final_PresentationFinal_Presentation
Final_Presentation
 
Taming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup HamburgTaming the Monolith - Microservices Meetup Hamburg
Taming the Monolith - Microservices Meetup Hamburg
 
An introduction to Microservices
An introduction to MicroservicesAn introduction to Microservices
An introduction to Microservices
 
Spring IO '15 - Developing microservices, Spring Boot or Grails?
Spring IO '15 - Developing microservices, Spring Boot or Grails?Spring IO '15 - Developing microservices, Spring Boot or Grails?
Spring IO '15 - Developing microservices, Spring Boot or Grails?
 
Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015
Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015
Breaking the monolith at jobandtalent - AWS Summit Barcelona 2015
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Evolving toward Microservices - O’Reilly SACON Keynote
Evolving toward Microservices  - O’Reilly SACON KeynoteEvolving toward Microservices  - O’Reilly SACON Keynote
Evolving toward Microservices - O’Reilly SACON Keynote
 
Monolith to Microservices - O’Reilly Oscon
Monolith to Microservices - O’Reilly OsconMonolith to Microservices - O’Reilly Oscon
Monolith to Microservices - O’Reilly Oscon
 
Software Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based ArchitecturesSoftware Architectures, Week 3 - Microservice-based Architectures
Software Architectures, Week 3 - Microservice-based Architectures
 
From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015From the Monolith to Microservices - CraftConf 2015
From the Monolith to Microservices - CraftConf 2015
 
Pragmatic Microservices
Pragmatic MicroservicesPragmatic Microservices
Pragmatic Microservices
 
Cloud Native Java Microservices
Cloud Native Java MicroservicesCloud Native Java Microservices
Cloud Native Java Microservices
 
software architecture
software architecturesoftware architecture
software architecture
 
Serverless - When to FaaS?
Serverless - When to FaaS?Serverless - When to FaaS?
Serverless - When to FaaS?
 

Similar to Grails Monolith to Microservice to FaaS

Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud FoundryJax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud Foundrymartinlippert
 
今Serverlessが面白いわけ
今Serverlessが面白いわけ今Serverlessが面白いわけ
今Serverlessが面白いわけYoichi Kawasaki
 
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Amazon Web Services
 
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유Soowan Lee
 
Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Jim Dowling
 
Stratos and PaaS for London Java Community
Stratos and PaaS for London Java CommunityStratos and PaaS for London Java Community
Stratos and PaaS for London Java CommunityPaul Fremantle
 
WSO2Con EU 2015: Understanding the API Management Platform
WSO2Con EU 2015: Understanding the API Management PlatformWSO2Con EU 2015: Understanding the API Management Platform
WSO2Con EU 2015: Understanding the API Management PlatformWSO2
 
Fowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing WorkshopFowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing WorkshopMark Masterson
 
Introducing apache stratos (incubating) & wso2 paa s foundation
Introducing apache stratos (incubating) & wso2 paa s foundationIntroducing apache stratos (incubating) & wso2 paa s foundation
Introducing apache stratos (incubating) & wso2 paa s foundationLakmal Warusawithana
 
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010Adrian Trenaman
 
Hasura 2.0 Webinar
Hasura 2.0   WebinarHasura 2.0   Webinar
Hasura 2.0 WebinarHasura
 
Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Manish Pandit
 
Cloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersBurr Sutter
 
Serverless Pune meetup 3
Serverless Pune meetup 3Serverless Pune meetup 3
Serverless Pune meetup 3Vishal Biyani
 
The Crazy Service Mesh Ecosystem
The Crazy Service Mesh EcosystemThe Crazy Service Mesh Ecosystem
The Crazy Service Mesh EcosystemAll Things Open
 
All things open 2019 crazy-sm-ecosystem
All things open 2019 crazy-sm-ecosystemAll things open 2019 crazy-sm-ecosystem
All things open 2019 crazy-sm-ecosystemLin Sun
 
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...Ludovic Piot
 
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptxIBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptxGeorg Ember
 

Similar to Grails Monolith to Microservice to FaaS (20)

Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud FoundryJax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
 
今Serverlessが面白いわけ
今Serverlessが面白いわけ今Serverlessが面白いわけ
今Serverlessが面白いわけ
 
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
Mythical Mysfits: Monolith to Microservices with Docker and Fargate - MAD305 ...
 
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
 
Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning Building Hopsworks, a cloud-native managed feature store for machine learning
Building Hopsworks, a cloud-native managed feature store for machine learning
 
Stratos and PaaS for London Java Community
Stratos and PaaS for London Java CommunityStratos and PaaS for London Java Community
Stratos and PaaS for London Java Community
 
WSO2Con EU 2015: Understanding the API Management Platform
WSO2Con EU 2015: Understanding the API Management PlatformWSO2Con EU 2015: Understanding the API Management Platform
WSO2Con EU 2015: Understanding the API Management Platform
 
Fowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing WorkshopFowa Miami 09 Cloud Computing Workshop
Fowa Miami 09 Cloud Computing Workshop
 
Introducing apache stratos (incubating) & wso2 paa s foundation
Introducing apache stratos (incubating) & wso2 paa s foundationIntroducing apache stratos (incubating) & wso2 paa s foundation
Introducing apache stratos (incubating) & wso2 paa s foundation
 
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
 
Hasura 2.0 Webinar
Hasura 2.0   WebinarHasura 2.0   Webinar
Hasura 2.0 Webinar
 
Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018
 
Cloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java Developers
 
Serverless .NET on AWS
Serverless .NET on AWS Serverless .NET on AWS
Serverless .NET on AWS
 
Ruby in the Clouds
Ruby in the CloudsRuby in the Clouds
Ruby in the Clouds
 
Serverless Pune meetup 3
Serverless Pune meetup 3Serverless Pune meetup 3
Serverless Pune meetup 3
 
The Crazy Service Mesh Ecosystem
The Crazy Service Mesh EcosystemThe Crazy Service Mesh Ecosystem
The Crazy Service Mesh Ecosystem
 
All things open 2019 crazy-sm-ecosystem
All things open 2019 crazy-sm-ecosystemAll things open 2019 crazy-sm-ecosystem
All things open 2019 crazy-sm-ecosystem
 
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
 
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptxIBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
 

Grails Monolith to Microservice to FaaS

  • 1. GRAILS MONOLITH TO MICROSERVICE TO FAAS Created by /Michael Wyszinski @MikeWyszinski
  • 2. ABOUT ME Coding professionally since 1997... Grails user/fan since 2009-ish Principal Architect@WestconComstor
  • 3. OVERVIEW Why this topic? Our Grails Application Microservice & FaaS Architecture FaaS Demo Grails monolith -> Microservices Grails monolith -> FaaS Conclusion
  • 4. OUR GRAILS "MONOLITH" - HISTORY Started life in 2007 using proprietary javaspace based architecture... In 2013, ported to grails 2.x over 6 months... Java Groovy JavaScript 0 200k 400k 600k loc ­ pre­Grails loc ­ Grails We were also able to leverage the grails ecosystem: GORM, shiro plugin, audit plugin, dbmigration etc.. Our Team ♥'s Grails!
  • 5. OUR GRAILS "MONOLITH" - FEATURES SaaS, cloud service brokerage Quote, Order, Manage, Bill many cloud products via a single application Global tenant base Tenants are: internal users, resellers, vendors, end- customers Custom code per tenant
  • 6. OUR GRAILS "MONOLITH" - COMPONENTS Component Description Artefact core shared "core": 67 domain classes, 66 services, multi- tenancy plugin, audit plugin, etc JAR api REST API WAR backend runs async jobs (order processing & provisioning, etc) triggered by rabbitMQ messages WAR shell run custom shell scripts manually/cron N/A portal angularjs portal for all users/tenants TAR admin-ui semi auto-generated grails MVC app for internal power users(to be decommisioned) WAR
  • 7. WHAT ARE MICROSERVICES? “In short, the microservice architectural style [1] is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery.” - martinfowler.com
  • 8. DEVELOPING MICROSERVICES scaling unit: per μ-service concurrency: developer de ned deployment: developer de ned infrastructure: devops managed
  • 9. WHAT IS SERVERLESS/FAAS? “Serverless can also mean applications where some amount of server-side logic is still written by the application developer but unlike traditional architectures is run in stateless compute containers that are event- triggered, ephemeral (may only last for one invocation), and fully managed by a 3rd party. One way to think of this is ‘Functions as a service / FaaS” - martinfowler.com servers DO exist. ...However, they are not accessible to developers, hence "serverless"
  • 11. ALL FAAS PLATFORMS... ...implement smallest possible μ-service -> f(x) = y ...are event-driven (platform speci c events) ...have an HTTP API event trigger ...support multiple f(x) runtimes (jvm, python, nodejs, c#, go, etc) ...disposable runtime env instanciated per f(x) invocation ...runtime env resources (RAM/CPU) con gurable per f(x)
  • 12. FAAS PROVIDERS ONLY HOSTED Amazon AWS Lambda Microsoft Azure Functions Google Cloud Functions + many others... OPEN SOURCE IBM OpenWhisk https://funktion.fabric8.io/ https://github.com/b rsh/serverless-docker + more all the time...
  • 14. HELLOWORLD - BUILD apply plugin: 'java' apply plugin: 'groovy' repositories { mavenCentral() } sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { compile ( 'org.codehaus.groovy:groovy-all:2.4.7', 'com.amazonaws:aws-lambda-java-core:1.1.0', 'com.amazonaws:aws-lambda-java-log4j:1.0.0', 'com.fasterxml.jackson.core:jackson-core:2.8.5', 'com.fasterxml.jackson.core:jackson-databind:2.8.5',
  • 15. HELLOWORLD - CONFIG service: groovy-hello provider: name: aws runtime: java8 memorySize: 512 cfLogs: true package: artifact: build/distributions/hello.zip functions: hello: handler: com.serverless.HelloWorldHandler events: - http: path: helloworld
  • 16. HELLOWORLD - HANDLER package com.helloworld class HelloWorldHandler implements RequestHandler<Map<String, Object>, ApiGateway @Override public ApiGatewayResponse handleRequest(Map<String, Object> input, Contex LOG.info("received: " + input); //Process the request Response responseBody = new Response("HelloWorld!", input); return ApiGatewayResponse.builder() .setStatusCode(200) .setObjectBody(responseBody) .build(); } }
  • 17. DEVELOPING FAAS scaling unit: f(x) concurrency: f(x), "in nite" * deployment: f(x) infrastructure: platform provided
  • 18. FAAS CAVEATS Latency: Cold start times Hosted Limits: deployed code size, execution time limits, concurrent invocs, etc
  • 19. EXAMPLE LIMITS - AWS LAMBDA
  • 20. FAAS COSTS Traf c Patterns Determines "Raw" savings Ef ciency Gains; Maintenance & Ops not re ected in Bill "in nite" scale! in nitly large bill during DDOS?
  • 21. SERVERLESSCALC.COM Calculating cost for AWS Lambda, Azure Functions, Google Cloud Functions, and IBM OpenWhisk Number of Executions Estimated Execution Time (ms) Serverless Cost Calculator (beta) Serverless Cost Calculator Peter Sbarski and the A Cloud Guru Team. Grab our book Number of Executions  © Peter Sbarski (A Cloud Guru) Design: HTML5 UP   
  • 22. GRAILS MONOLITH -> MICROSERVICE 1. refactor: shared domain + api + backend projects into... N-deployable artefacts along business functions (OrderService, QuoteService, etc) Artefacts could contain both REST & async jobs 2. that's pretty much it... 3. plugins? shared domains? versioning eveything..
  • 23. GRAILS MONOLITH -> FAAS grails create-app my-faas --profile rest-api cd my-faas grails create-domain-class foo grails grails generate-all my.faas.Foo grails prod war ls -lh build/libs/hello-faas-0.1.war -rw-r--r-- 1 mike staff 60M Jan 2 00:23 build/libs/hello-faas-0.1.war 1. Remove dependencies to shrink lib < 50MB 2. no tomcat... 3. found mock! https://github.com/bleshik/aws-lambda-servlet 4. refactor to mock servlet container wait. does grails behavior depend on servlet lifecycle? grails application context? do plugins I'm using depend on servlet lifecycle? 5. felt like a lot of more investigation required...
  • 24. TAKEAWAY FaaS now provides functionality that overlaps with Grails (and prob most frameworks...) Tomcat replaced by API gateway ✘ API gateways provide caching, SSL term, auth, SSO, etc... Not trivial to port Grails(and prob most frameworks) to FaaS
  • 25. INTERESTING FAAS FEATURES Isolated runtime env -> f(x) dont compete for shared heap/cpu Concurrency, programming model can be single threaded... ..but, shared resources (DBs,etc) still need to handle concurrent load async io? Disposable runtime env -> run untrusted code
  • 26. FINAL REMARKS Grails Monolith to Microservices? :-) Grails Monolith to FaaS? Prob Not Impossible. Grails Still rocks ;-) “ 1. Almost all the successful microservice stories have started with a monolith that got too big and was broken up 2. Almost all the cases where I've heard of a system that was built as a microservice system from scratch, it has ended up in serious trouble. ” - martinfowler.com