µServices Architecture using Groovy
http://bit.ly/microservices-groovy
Agenda
- What? Why? How? ROI?
- Getting Groovy
- Ratpack Framework
- Peek a Boot & Grails 3
- Case Study
- Q/A
- Ale
What?
Microservice architectural style 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.
- Martin Fowler
Why?
Because monolithic apps lack:
- Scalability
- Flexibility
- Modularity
- Portability
- Decentralization
Monolithic Apps
- Non Modular
- Unscalable
- Inter-dependent components are dumb when worked alone
- Huge turn around time for changes
- Becoming less productive when "Cloud" is in context
- "Build - Test - Ship" cycle is time consuming
- Fragile when complexity increases
µServices
- Scalable
- Integration By Functioning Parts
- Decentralized
- Domain Specific Boundaries
- Distributed Governance/Ownership
- Suits Continuous Delivery
- Two Pizza Team
- Fine Grained Failsafe Mechanism
- Modular
Pros
- Smaller services that are independent & easy to understand
- Relatively simple and adheres to Single Responsibility Principle
- Embedded Containers per service (remember Grails? on steroids)
- Separation Of Concern
- Multiple services developed and deployed independently communicate RESTfully
- Independent of technology stacks
Cons
- Number of services to mentain
- Deciding on inter-service communication mechanism
- Implementing ATOMICITY (distributed transactions) among services
- Synchronization between teams owning services (Thanks to pull requests)
- Divergence in Organizational Standards
Getting Groovy
MetaProgramming
DSL
Dynamic
Optional Type
Frameworks
- Ratpack
- Spring Boot
- Dropwizard
- Vert.x
- Grails
Ratpack
- Java 8 , Netty , Google Guava and Reactive Streams .
- Specific support for Groovy
- Non-blocking & Event based API (Async)
- Google Guice for DI
@GrabResolver("https://oss.jfrog.org/artifactory/repo")
@Grab("io.ratpack:ratpack-groovy:0.9.4")
import static ratpack.groovy.Groovy.*
ratpack {
handlers {
get {
render "Hello World"
}
}
}
http://localhost:5050
v0.9.11 (released 12/01)
Add-ons
-
Gradle Integration
- ratpack-gradle
- ratpack-groovy (dep)
- ratpack-java (dep)
- Springloaded & GORM integration
-
npm install generator-angular-ratpack
- Stand-alone Spring applications
- Embedded Tomcat or Jetty directly.
- Convention over Configuration
- Deployable Fat JARs
- Opinionated
- Metrics, health checks and externalized configuration
- no code generation and no requirement for XML configuration
Gradle Dependency
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.1.9.RELEASE")
}
Spring Boot App
package hello;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
Great.. but not so Groovy!!!
Grrrrooooovyyy
//App.groovy
@RestController
class SampleController {
@RequestMapping("/")
String home() {
return "Hello World!"
}
}
$ spring run App.groovy
$ curl localhost:8080
Hello World!
Grails 3.0 Sneak Peek
by Graeme Rocher in S2GX - 2014
µServices Followers?
A single missing semicolon brought down the entire (monolithic) Netflix website for several hours in 2008. #reInvent — Chris Eng (@chriseng)
NetFlix
( NetFlix OSS)
Revisit
Q/A
References & Resources:
& more...
Thank You
MicroServices using Groovy
By Dhiraj Mahapatro
MicroServices using Groovy
- 5,755