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 preGrails
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
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...
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?
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