microservices and friends

39
MicroServices & Friends Platmasphere Tech Stack @YunZhiLin

Upload: yun-zhi-lin

Post on 16-Jul-2015

158 views

Category:

Technology


0 download

TRANSCRIPT

MicroServices & FriendsPlatmasphere Tech Stack

@YunZhiLin

1. Architecture1. Architecture

2. DevOps2. DevOps

3. Server Stack3. Server Stack

4. Client Stack4. Client Stack

5. Profit!5. Profit!

EnterpriseEnterprise Architecture Architecture

Enterprise ArchitectEnterprise Architect

Don't have one - shared responsibility.Self organising teamBut we make decisions a lot faster.We do have some instead Enterprise Architect Jokes

Service EvolutionService Evolution

Sources: PWC research

Developer Evolution Developer Evolution

We HadWe HadTraditional layeredarchitecture:

Silo'ed teams of BA,Designers and Dev( ).Delivery bottlenecksLack of collaborationand re-useFrustrating todebug/supportDifficult to deploy

Conway's Law

We now have:We now have:MicroServices basedarchitecture:

Cross functionaldesign/dev ofservicesParallel deliveryRe-usablemodules acrossclient and serverEasy monitoringand diagnostics.ContinuousDelivery

ArchitectureArchitectureCommunal DesignCommunal Design

DecisionsDecisions

KISSKISS

(Keep It Simple Stupid)(Keep It Simple Stupid)

No App Servers/WarNo App Servers/WarBloated in size, hogs resources, memoryleak, restartsAnother layer of configuration and complexityRun multiple apps 1 app per server, no isolationProvide Infrastructure part of the appOps - provides own toolsets vs external choices.EJB support - no need in this day and age$$$ and require specialists

Sources: , App Servers are Dead Stop wasting money onApplication Servers

Use Standalone AppsUse Standalone AppsSelf containedConfigure you app, not the app serverResource isolation via docker containersJava - Jetty; Netty, Undertow, or just Main()Node.js - Harp, ExpressRuby - Rails, SinatraMore on Framework later

Reference: Heroku for Java

Enterprise Service BusEnterprise Service Bussolves all integration problems in a boxfail proof

ESB In RealityESB In RealityOne massive app server with all the same issues

MicroServices MicroServices

Independently ScalableFault Tolerant

Free

Decentralised GovernanceDecentralised Data

Smart endpoints

vs ESBvs ESBCentral orchestration.Canonical Data ModelMiddleware BottleneckSingle point of failureSmart Pipeline$$$$$$

Need pub/sub or queuing: try light weight broker-lessmessaging such as ZeroMQ.

JSON/RESTJSON/REST vs SOAP/WSDLvs SOAP/WSDL

{ "streetNumber": "80", "streetName": "Clarence", "suburb": "Sydney"}

Text

<?xml version="1.0" encoding="UTF-8" ?><Property> <streetNumber>80</streetNumber> <streetName>Clarence</streetName> <suburb>Sydney</suburb></Property

PUT /hostname/properties/ <service name="Properties"> <documentation>WSDL File for PropertyService</documentation <port binding="tns:Properties" name="Properties_Port" <soap:address location="http://hostname/propeties/" </port></service>

SwaggerSwaggerWho needs WSDL or JavaDoc when you have Swagger

#YoloSwag!#YoloSwag!

Dev OpsDev Ops

Who Does Dev OpsWho Does Dev OpsNo one does Dev Ops for the sake of Dev OpsDevOps is a means to an end: build good softwareEvery good engineer should be Dev Ops minded

Continuous DeliveryContinuous Delivery1. GitHub triggers artefact Snap-CI pipeline

2. Upload tested artefact to Bintray

Continuous DeliveryContinuous Delivery3. Push to Quay.io to build Docker

4. Run Container on Tutum PaaS

Continuous DeliveryContinuous Delivery5. Monitor Services using NewRelic

Why DockerWhy DockerResource IsolationImmutable and PortableLightweight compared to VM

Small and Fast DockerSmall and Fast DockerTake advantage of caching in DockerfileUse small base images such as BusyBoxCI friendly: fast build is a good build

Server StackServer Stack

Picking a FrameworkPicking a FrameworkUse the right tool for the right jobDo prototype spikes that cover key requirementsConsider the learning curve and team skill setInfrastructure are on-demand, don't feel restrictedPerformance will matter eventually, but not day 1Reference benchmarks, or roll your ownTechEmpower

TechEmpower BenchmarksTechEmpower BenchmarksDon't always believe the hype!

Frameworks we useFrameworks we useRails - the original developer productivity framework Dropwizard - Production ready out of boxSpring Boot - For when you really need SpringRatPack - Not so easy to do the right thing

GradleGradle vs Mavenvs Mavenrepositories { jcenter() maven { url "http://dl.bintray.com/trunkplatform/osworkflow" } }}

dependencies { compile group: 'com.trunkplatform.opensymphony', name: 'osworkflow', version: '3.1.4'}

<repositories> <repository> <snapshots> <enabled>false</enabled> </snapshots> <id>bintray-trunkplatform</id> <name>bintray</name> <url>http://dl.bintray.com/trunkplatform/osworkflow </repository></repositories>

<dependencies> <dependency> <groupId>com.trunkplatform.opensymphony</groupId <artifactId>osworkflow</artifactId> <version>3.1.4</version> <scope>compile</scope> </dependency></dependencies>

Postgres and MySqlPostgres and MySqlTrnk.io - MySQL via Google CloudSQL Platmasphere - Postgres via Amazon RDSPostgres offers multi-tenant functionality

Dependency InjectionDependency InjectionInject dependencies as needed, rather than passingthrough different constructors.Swapping in stub implementations for testsSpring and Guice equally good. Right tool for right job

Client StackClient Stack

AngularJSAngularJSMVCDependency InjectionStatic pagesMade by Google (?)

Gulp Gulp http://markdalgleish.github.io/presentation-build-wars-gulp-vs-grunt/Streaming Builds

gulp.task('package', function() { return gulp.src([ 'app/**/*', 'gulp_tasks/*', 'newrelic.js', 'package.json' ], {"base": .pipe(tar('platmasphere-client.tar')) .pipe(gzip()) .pipe(gulp.dest('.'));});

HarpHarpSimple lightweight webserverPrecompiles CSS and HTML templatesNo need to write any server app code

var express = require('express')var app = express()

app.get('/', function (req, res) { res.send('Hello World!')})

var server = app.listen(9000, function () {

var host = server.address().address var port = server.address().port

console.log('Example app listening at http://%s:%s'

})

bash$ harp server .------------Harp v0.14.0 – Chloi Inc. 2012–2014Your server is listening at http://localhost:9000/Press Ctl+C to stop the server------------

Profit!Profit!

QuestionsQuestions