SlideShare a Scribd company logo
Microservices and FP
Michael Neale
@michaelneale
developer.cloudbees.com
Wednesday, 9 October 13
Microservices and FP
Given that:
We have lots of services
- Everything has an API
Functional programming:
- quality improvements, popular
- applied easily to “new” services/projects
Combine them!
Wednesday, 9 October 13
Definitions
Functional programming:
- avoid/manage side effects
- immutability over mutation
- higher order functions
- first class functions
- composition using functions over OO
Wednesday, 9 October 13
Definitions
Micro-service:
- remotely accessible service (typically http)
- does “one thing” (and does it well?)
- executes stand alone in a container (JVM - in this
case)
- may depend on other services
- can be composed into a larger service
Wednesday, 9 October 13
Definitions
Micro-service:
- “small”
- independently deployed
- loosely coupled
- not necessarily reusable (but may be)
Wednesday, 9 October 13
Definitions
Like a unix command line app that does ONE THING
AND ONE THING ONLY!
service1 | service2 | service3 ....
Wednesday, 9 October 13
Example scenario
Wednesday, 9 October 13
Jenkins CI
PaaS repos autoscale
management console web apps
how to compose???
provisioning
licencingsubscriptions
Wednesday, 9 October 13
Identify some micro
services
repos: artifact storage
- store blobs in users account (via s3)
autoscale:
- look at a stream of stats - decide to scale app
(note: won’t scale app - just recommends)
subscriptions:
- check entitlements, record usage
Wednesday, 9 October 13
All in common:
All small!
All do one thing!
Wednesday, 9 October 13
Aside: FP (more later)
Some services lend themselves to “purity”
eg: Automatic scaling
F(last minute stats) = recommendation to scale up,
or down (or no change)
No state, no persistence. Perfect candidate for FP.
Wednesday, 9 October 13
Why not monolithic?
Can easily do
@Produces(MediaType.JSON)
@Path("/apps")
@POST
...
Thanks to jax-rs in one app? why not? Different
endpoints via @Path, different methods, different
classes?
Wednesday, 9 October 13
Why not monolithic?
Apps grow (teams grow too!)
Different parts change at different rates
Different execution container needs (resources)
Different teams?
Company grows?
But most of all:
Wednesday, 9 October 13
Why not monolithic?
Fear.
Risk.
Fear of deploying a change.
Risk of trying a new technique, new framework.
Wednesday, 9 October 13
Why not monolithic?
Deploying a change to a microservice does not
increase blood pressure as much as deploying the
ONE MASSIVE APP THAT RUNS EVERYTHING
Wednesday, 9 October 13
Wednesday, 9 October 13
Monolithic debugging
(Often in production)
???
Wednesday, 9 October 13
micro-service debugging
Wednesday, 9 October 13
Shift to dev-ops
More deployment expected
More *people* doing the deployment
Wednesday, 9 October 13
Smooth deployment
Microservices need:
- easy rollback
- no “over the wall” deployment
- easy as-needed deployment
- accessible deploy environment
A PaaS can help (private or public) - they were born
for this.
Wednesday, 9 October 13
Transport
Typically (but not always) HTTP
Typically (but not always) JSON
(autoscale service was message bus + thrift name/
value pairs)
But *are* always loosely coupled (ie never RMI)
Wednesday, 9 October 13
Containers
Execution environment:
- anything really
- consumers of APIs don’t care
- but developers do, deployers do
- JVM ideal: enough controls/constraints
- many languages
- many frameworks
If you had to pick one: JVM wins.
Wednesday, 9 October 13
Convinced?
By this point I hope I have convinced you
microservices are good.
Right?
Wednesday, 9 October 13
Wednesday, 9 October 13
Functional Programming
with microservices
First, some background...
Wednesday, 9 October 13
Context
New Company
New Team
New Product
You might not be this “lucky”
Wednesday, 9 October 13
History
2010 Started: JVM stack parts - Scala not
controversial (I had experience) - working mostly
“lone wolf”
2011 - another team added - brought Erlang
Wednesday, 9 October 13
Erlang!
Me
other team members
Wednesday, 9 October 13
More FP
Given “success” with Scala, more FP (services,
languages) was not viewed as a great risk.
Wednesday, 9 October 13
Observation
FP means one person can do more &&
People like me like to work alone
∴ risk of staying with one-person-per micro service
(is this a bad thing?)
Wednesday, 9 October 13
Objections and resistance
Ask why:
- resistance to the “new” (unnecessary risk)
- resistance to FP ideas (hype?)
- polyglot fear
(realistically multiple languages will be used)
Wednesday, 9 October 13
Maintainability objection
It goes:
- how will anyone be able to maintain this after you?
My Experience:
- projects featuring FP handed over successfully
- new developers able to pick up FP easily
- seasoned developers too
Wednesday, 9 October 13
Where we may differ
Small teams - many systems.
∴ Little overlap in jobs.
We get to use a great PaaS !
(our own!) for all these micro services
Wednesday, 9 October 13
What did we do with FP
Manage horrendous public cloud APIs
Automatic scaling (microservice)
Github crawling (microservice)
Subscription/signup/entitlements (microservice)
... and microservices
Wednesday, 9 October 13
Surprisingly practical things
No real calculations, no explicit maths.
Just boring every day error prone stuff.
Wednesday, 9 October 13
For example (provisioning)
Wednesday, 9 October 13
Providore Evil cloud
api
Build masters
build workers Workspace
storage
Wednesday, 9 October 13
New build required. Check the pool, talk to the Evil
api, ask for a new server, it fails, ask again. Wait for
server to be up, no, I mean really up.
Ask for a new disk, wait for a new disk, it fails, try
again, attach the new disk, is the disk attached?
fails, try again, damn it the snapshot isn’t available.
The problem:
Wednesday, 9 October 13
How can we solve this?
TDD? problems only manifest under load/in-
production. APIs are buggy, change over time.
Industry best practice: hack something together as a
script and some of the time it works.
Can FP help us?
Wednesday, 9 October 13
Yes
Types (providore is written in scala)
- Specifically: Option, Either
- Closed Data Types (servers only in so many states)
The M word: Monads
Currying
Wednesday, 9 October 13
Cloud API
launch_server: Server
at best hopes to be:
launch_server: Option[Server]
launch_server: Either[Server, OhGodWhyWhyWhy]
(not an actual pure function of course)
Wednesday, 9 October 13
Cloud Monad
Cloud APIs are like IO
Slow, horrible, misbehaving IO
...and then the APIs other people write
All want to be monadic
Wednesday, 9 October 13
val validation: String / Subscription = (for {
account <- extractAccount
_ <- validateSubscription(account)
callback <- extractCallBack
plan <- validatePlan
billing_day <- extractBillingDay
subscription <- createSub(account, plan, callback, ...
} yield subscription).run(req.body)
(scala) ReaderT to help you compose
http://debasishg.blogspot.com.au/2011/07/
monad-transformers-in-scala.html
Need to “organise code in monadic way”
Wednesday, 9 October 13
Types
So hard to catch things without them
Monadic IO + types mean you catch things before
you try
Trying/experimenting can be $$ expensive...
(still learning this, all new to me)
Wednesday, 9 October 13
Types helped with
Ignored messages
Bad pattern matching
Misconfiguration/timing of server creation
Avoiding “stringly typed” messages
All “real world” things types have help us catch with
a friendly compile error**
** may not actually be friendly
Wednesday, 9 October 13
Types didn’t help with...
Wednesday, 9 October 13
def ec2
Fog::Compute.new(:provider => 'AWS',
:aws_secret_access_key => ENV['EC2_SECRET_KEY'],
:aws_access_key_id => ENV['EC2_ACCESS_KEY'])
end
 
def tenured? (instance)
instance.created_at && (instance.created_at < Chronic.parse('50 minutes
ago'))
end
 
def alive? (instance)
instance.state == 'running' or instance.state == 'stopped'
end
 
zombies = ec2.servers.select { |i| i.tags.empty? && tenured?(i) && alive?(i) }
Parallel.each(zombies, :in_threads => 15) do |zombie|
begin
puts "Terminating zombie node #{zombie.id}"
ec2.servers.get(zombie.id).destroy
end
end
Wednesday, 9 October 13
True story
Wednesday, 9 October 13
Currying
Server lifecycle: Reserved->Launching->Update
(user data)->Volume Create->Volume Attach-
>initialise/start
Accumulate setup data via partial application
Instead of an object that has mutating state, a
function you partially apply to accumulate data.
Good “beginner” FP concept (powerful, simple)
Wednesday, 9 October 13
Small things
But every little bit helps.
The pure FP is my ideal, rarely reached (so far)
Wednesday, 9 October 13
Another example
(autoscale)
Wednesday, 9 October 13
Message Bus Autoscale
Controller
apps/statistics
Wednesday, 9 October 13
Auto scaling
F(last minute stats, previous data
window) -> “Suggestion” to scale up, or down
(or in or out)
Fundamentally calculation, fundamentally functional.
Wednesday, 9 October 13
Side effects
Push out side effects to other side of the message
bus
Let a nasty app handle the side effects
Messages are signals, suggestions, idempotent
Wednesday, 9 October 13
Advocating to Developers
Don’t “sell” to your developers by:
- saying monad too often
- saying “it’s easy”
- showing that it can be just as easy/familiar as what
they have
Instead...
Wednesday, 9 October 13
Find the functions
Find the functions in what they do
Find the calculations (eg core of autoscaling)
Advanced:
Separate the program definition from the execution
(monads)
Intermediate:
Currying, Higher order functions, Types (good ones)
Wednesday, 9 October 13
‘Unlearning’ OO
Clojure: excellent at teaching people to forget about
OO.
Scala: challenge. Temptation always there.
∴ Use object/package as namespace (avoid classes)
Aside: lack of implicit state allows “Erlang Magic”
Wednesday, 9 October 13
Some Frameworks for FP &
Microservices
Quick tour:
Wednesday, 9 October 13
Quick development for web apps and APIs
RESTful by design
“batteries included” - has everything.
Easy reuse of all java libraries.
www.playframework.com
Wednesday, 9 October 13
Wednesday, 9 October 13
Easy deployment (jar/zip file)
Can support DBs/evolution
Excellent JSON/http/web support
Security, Async, Background jobs, and more
Scala or Java.
Wednesday, 9 October 13
Compojure: just enough web framework
Light - small apps
Deploy as war, or embedded jetty
Great libraries, reuse java libs
Effortless JSON -> clojure
https://github.com/weavejester/compojure
Wednesday, 9 October 13
Wednesday, 9 October 13
(:use cheshire.core)
(let [clojure-data (parse-string json-data)])
(generate-string clojure-data)
;;magic!
https://github.com/dakrone/cheshire
Wednesday, 9 October 13
To the Cloud!
Want to try things at your company:
Cloud Platforms (hint! vendor shilling!) make it easy
to try things out that may be used seriously.
Clojure anywhere, Scala anywhere
Say “cloud cloud” a lot and people will listen.
Wednesday, 9 October 13
Mixed language projects
Good idea??
Relevant to JVM
Ease-into-it
Jury is out...
Wednesday, 9 October 13
Bad questions to hear
(when advocating)
If you hear these asked, probably will have a bad
time:
How will we hire people?
Does it work for large teams?
Wednesday, 9 October 13
Final Observation
Developers who have fondness for emacs/vim (over
IDE) find things easier
FP invites “change this small bit, see what happens”
exploration
No real tool barriers.
If I can do this, anyone can.
Wednesday, 9 October 13
Conclusion
FP and Microservices *naturally* go together
Can be about Risk Reduction in new rapid
deployment world
Cloud
A good place to try FP
Wednesday, 9 October 13
Thank you
Michael Neale
https://twitter.com/michaelneale
http://www.cloudbees.com
Wednesday, 9 October 13

More Related Content

What's hot

Overview of Site Reliability Engineering (SRE) & best practices
Overview of Site Reliability Engineering (SRE) & best practicesOverview of Site Reliability Engineering (SRE) & best practices
Overview of Site Reliability Engineering (SRE) & best practices
Ashutosh Agarwal
 
Finally, easy integration testing with Testcontainers
Finally, easy integration testing with TestcontainersFinally, easy integration testing with Testcontainers
Finally, easy integration testing with Testcontainers
Rudy De Busscher
 
Refactoring
RefactoringRefactoring
Refactoring
Ricardo Terra
 
Kubernetes University, Cap sur l’orchestration Docker
Kubernetes University, Cap sur l’orchestration DockerKubernetes University, Cap sur l’orchestration Docker
Kubernetes University, Cap sur l’orchestration Docker
Jean-Baptiste Claramonte
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
Ravindu Fernando
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
Kumar Shìvam
 
VM Job Queues in CloudStack
VM Job Queues in CloudStackVM Job Queues in CloudStack
VM Job Queues in CloudStack
ShapeBlue
 
Source control
Source controlSource control
Source control
Sachithra Gayan
 
Showdown CI/CD - TeamCity
Showdown CI/CD - TeamCityShowdown CI/CD - TeamCity
Showdown CI/CD - TeamCity
Boyan Mihaylov
 
Integration testing for microservices with Spring Boot
Integration testing for microservices with Spring BootIntegration testing for microservices with Spring Boot
Integration testing for microservices with Spring Boot
Oleksandr Romanov
 
DevOps for beginners
DevOps for beginnersDevOps for beginners
DevOps for beginners
Pradeep Patel, PMP®
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
Mario Sangiorgio
 
SonarQube Presentation.pptx
SonarQube Presentation.pptxSonarQube Presentation.pptx
SonarQube Presentation.pptx
Satwik Bhupathi Raju
 
Intégration et livraison continues des bonnes pratiques de conception d'appli...
Intégration et livraison continues des bonnes pratiques de conception d'appli...Intégration et livraison continues des bonnes pratiques de conception d'appli...
Intégration et livraison continues des bonnes pratiques de conception d'appli...
Amazon Web Services
 
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
Simplilearn
 
API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_Postman
Mithilesh Singh
 
Git workflows
Git workflowsGit workflows
Git workflows
Xpand IT
 
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões ArquiteturaisMVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
Jorge Tressino Rua
 
AWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWSAWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWS
Amazon Web Services
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
CodeOps Technologies LLP
 

What's hot (20)

Overview of Site Reliability Engineering (SRE) & best practices
Overview of Site Reliability Engineering (SRE) & best practicesOverview of Site Reliability Engineering (SRE) & best practices
Overview of Site Reliability Engineering (SRE) & best practices
 
Finally, easy integration testing with Testcontainers
Finally, easy integration testing with TestcontainersFinally, easy integration testing with Testcontainers
Finally, easy integration testing with Testcontainers
 
Refactoring
RefactoringRefactoring
Refactoring
 
Kubernetes University, Cap sur l’orchestration Docker
Kubernetes University, Cap sur l’orchestration DockerKubernetes University, Cap sur l’orchestration Docker
Kubernetes University, Cap sur l’orchestration Docker
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
VM Job Queues in CloudStack
VM Job Queues in CloudStackVM Job Queues in CloudStack
VM Job Queues in CloudStack
 
Source control
Source controlSource control
Source control
 
Showdown CI/CD - TeamCity
Showdown CI/CD - TeamCityShowdown CI/CD - TeamCity
Showdown CI/CD - TeamCity
 
Integration testing for microservices with Spring Boot
Integration testing for microservices with Spring BootIntegration testing for microservices with Spring Boot
Integration testing for microservices with Spring Boot
 
DevOps for beginners
DevOps for beginnersDevOps for beginners
DevOps for beginners
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
SonarQube Presentation.pptx
SonarQube Presentation.pptxSonarQube Presentation.pptx
SonarQube Presentation.pptx
 
Intégration et livraison continues des bonnes pratiques de conception d'appli...
Intégration et livraison continues des bonnes pratiques de conception d'appli...Intégration et livraison continues des bonnes pratiques de conception d'appli...
Intégration et livraison continues des bonnes pratiques de conception d'appli...
 
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
 
API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_Postman
 
Git workflows
Git workflowsGit workflows
Git workflows
 
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões ArquiteturaisMVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
MVC, MVP e MVVM: Uma Comparação de Padrões Arquiteturais
 
AWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWSAWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWS
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 

Similar to Microservices and functional programming

The InstallShield of the 21st Century – Theo Schlossnagle
The InstallShield of the 21st Century – Theo SchlossnagleThe InstallShield of the 21st Century – Theo Schlossnagle
The InstallShield of the 21st Century – Theo Schlossnagle
Chef Software, Inc.
 
Writing Applications at Cloud Scale
Writing Applications at Cloud ScaleWriting Applications at Cloud Scale
Writing Applications at Cloud Scale
Matt Ryan
 
How automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous DeliveryHow automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous Delivery
Edmund Siegfried Haselwanter
 
Infrastructure as Code with Chef / Puppet
Infrastructure as Code with Chef / PuppetInfrastructure as Code with Chef / Puppet
Infrastructure as Code with Chef / Puppet
Edmund Siegfried Haselwanter
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Ran Mizrahi
 
Engineering culture
Engineering cultureEngineering culture
Engineering culture
Pamela Fox
 
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
Xamarin
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Pablo Godel
 
Unlocked London - General Session
Unlocked London - General SessionUnlocked London - General Session
Unlocked London - General Session
Wayne Walls
 
Application Architectures in Grails
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in Grails
Peter Ledbrook
 
Proud to be polyglot!
Proud to be polyglot!Proud to be polyglot!
Proud to be polyglot!
NLJUG
 
Aloha on-rails-2009
Aloha on-rails-2009Aloha on-rails-2009
Aloha on-rails-2009
John Woodell
 
Docker Deployments
Docker DeploymentsDocker Deployments
Docker Deployments
Docker, Inc.
 
Introduction to NoSQL with Couchbase
Introduction to NoSQL with CouchbaseIntroduction to NoSQL with Couchbase
Introduction to NoSQL with Couchbase
Tugdual Grall
 
Green Shoots in the Brownest Field: Being a Startup in Government
Green Shoots in the Brownest Field: Being a Startup in GovernmentGreen Shoots in the Brownest Field: Being a Startup in Government
Green Shoots in the Brownest Field: Being a Startup in Government
C4Media
 
DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...
DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...
DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...
Amazon Web Services
 
Node.js and express
Node.js and expressNode.js and express
Node.js and express
JoaquimSerafim
 
Reactive design: languages, and paradigms
Reactive design: languages, and paradigmsReactive design: languages, and paradigms
Reactive design: languages, and paradigms
Dean Wampler
 
Tools/Processes for serious android app development
Tools/Processes for serious android app developmentTools/Processes for serious android app development
Tools/Processes for serious android app development
Gaurav Lochan
 
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and MobileOpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
Dierk König
 

Similar to Microservices and functional programming (20)

The InstallShield of the 21st Century – Theo Schlossnagle
The InstallShield of the 21st Century – Theo SchlossnagleThe InstallShield of the 21st Century – Theo Schlossnagle
The InstallShield of the 21st Century – Theo Schlossnagle
 
Writing Applications at Cloud Scale
Writing Applications at Cloud ScaleWriting Applications at Cloud Scale
Writing Applications at Cloud Scale
 
How automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous DeliveryHow automated cloud infrastructure setups can help with Continuous Delivery
How automated cloud infrastructure setups can help with Continuous Delivery
 
Infrastructure as Code with Chef / Puppet
Infrastructure as Code with Chef / PuppetInfrastructure as Code with Chef / Puppet
Infrastructure as Code with Chef / Puppet
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
 
Engineering culture
Engineering cultureEngineering culture
Engineering culture
 
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
 
Unlocked London - General Session
Unlocked London - General SessionUnlocked London - General Session
Unlocked London - General Session
 
Application Architectures in Grails
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in Grails
 
Proud to be polyglot!
Proud to be polyglot!Proud to be polyglot!
Proud to be polyglot!
 
Aloha on-rails-2009
Aloha on-rails-2009Aloha on-rails-2009
Aloha on-rails-2009
 
Docker Deployments
Docker DeploymentsDocker Deployments
Docker Deployments
 
Introduction to NoSQL with Couchbase
Introduction to NoSQL with CouchbaseIntroduction to NoSQL with Couchbase
Introduction to NoSQL with Couchbase
 
Green Shoots in the Brownest Field: Being a Startup in Government
Green Shoots in the Brownest Field: Being a Startup in GovernmentGreen Shoots in the Brownest Field: Being a Startup in Government
Green Shoots in the Brownest Field: Being a Startup in Government
 
DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...
DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...
DevOps Nirvana: Seven Steps to a Peaceful Life on AWS (ARC210) | AWS re:Inven...
 
Node.js and express
Node.js and expressNode.js and express
Node.js and express
 
Reactive design: languages, and paradigms
Reactive design: languages, and paradigmsReactive design: languages, and paradigms
Reactive design: languages, and paradigms
 
Tools/Processes for serious android app development
Tools/Processes for serious android app developmentTools/Processes for serious android app development
Tools/Processes for serious android app development
 
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and MobileOpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
OpenDolphin: Enterprise Apps for collaboration on Desktop, Web, and Mobile
 

More from Michael Neale

Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)
Michael Neale
 
Devoxx 2014 michael_neale
Devoxx 2014 michael_nealeDevoxx 2014 michael_neale
Devoxx 2014 michael_neale
Michael Neale
 
Cd syd
Cd sydCd syd
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
Michael Neale
 
Cors michael
Cors michaelCors michael
Cors michael
Michael Neale
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_neale
Michael Neale
 
Scala sydoct2011
Scala sydoct2011Scala sydoct2011
Scala sydoct2011
Michael Neale
 
Java one 2011_michaelneale
Java one 2011_michaelnealeJava one 2011_michaelneale
Java one 2011_michaelneale
Michael Neale
 
Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011
Michael Neale
 
Sjug aug 2010_cloud
Sjug aug 2010_cloudSjug aug 2010_cloud
Sjug aug 2010_cloud
Michael Neale
 
SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful design
Michael Neale
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009
Michael Neale
 
Osdc Complex Event Processing
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event Processing
Michael Neale
 
Scala Sjug 09
Scala Sjug 09Scala Sjug 09
Scala Sjug 09
Michael Neale
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
Michael Neale
 
Osdc Michael Neale 2008
Osdc Michael Neale 2008Osdc Michael Neale 2008
Osdc Michael Neale 2008
Michael Neale
 

More from Michael Neale (16)

Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)
 
Devoxx 2014 michael_neale
Devoxx 2014 michael_nealeDevoxx 2014 michael_neale
Devoxx 2014 michael_neale
 
Cd syd
Cd sydCd syd
Cd syd
 
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
 
Cors michael
Cors michaelCors michael
Cors michael
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_neale
 
Scala sydoct2011
Scala sydoct2011Scala sydoct2011
Scala sydoct2011
 
Java one 2011_michaelneale
Java one 2011_michaelnealeJava one 2011_michaelneale
Java one 2011_michaelneale
 
Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011
 
Sjug aug 2010_cloud
Sjug aug 2010_cloudSjug aug 2010_cloud
Sjug aug 2010_cloud
 
SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful design
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009
 
Osdc Complex Event Processing
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event Processing
 
Scala Sjug 09
Scala Sjug 09Scala Sjug 09
Scala Sjug 09
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Osdc Michael Neale 2008
Osdc Michael Neale 2008Osdc Michael Neale 2008
Osdc Michael Neale 2008
 

Recently uploaded

BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
Google Developer Group - Harare
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptxIntroduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
313mohammedarshad
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
Emerging Tech
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
bhumivarma35300
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
SynapseIndia
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
KAMAL CHOUDHARY
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
sunilverma7884
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
HackersList
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
maigasapphire
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
Zilliz
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
Edge AI and Vision Alliance
 
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSECHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
kumarjarun2010
 
Feature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptxFeature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptx
ssuser1915fe1
 

Recently uploaded (20)

BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptxIntroduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
 
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSECHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
CHAPTER-8 COMPONENTS OF COMPUTER SYSTEM CLASS 9 CBSE
 
Feature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptxFeature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptx
 

Microservices and functional programming

  • 1. Microservices and FP Michael Neale @michaelneale developer.cloudbees.com Wednesday, 9 October 13
  • 2. Microservices and FP Given that: We have lots of services - Everything has an API Functional programming: - quality improvements, popular - applied easily to “new” services/projects Combine them! Wednesday, 9 October 13
  • 3. Definitions Functional programming: - avoid/manage side effects - immutability over mutation - higher order functions - first class functions - composition using functions over OO Wednesday, 9 October 13
  • 4. Definitions Micro-service: - remotely accessible service (typically http) - does “one thing” (and does it well?) - executes stand alone in a container (JVM - in this case) - may depend on other services - can be composed into a larger service Wednesday, 9 October 13
  • 5. Definitions Micro-service: - “small” - independently deployed - loosely coupled - not necessarily reusable (but may be) Wednesday, 9 October 13
  • 6. Definitions Like a unix command line app that does ONE THING AND ONE THING ONLY! service1 | service2 | service3 .... Wednesday, 9 October 13
  • 8. Jenkins CI PaaS repos autoscale management console web apps how to compose??? provisioning licencingsubscriptions Wednesday, 9 October 13
  • 9. Identify some micro services repos: artifact storage - store blobs in users account (via s3) autoscale: - look at a stream of stats - decide to scale app (note: won’t scale app - just recommends) subscriptions: - check entitlements, record usage Wednesday, 9 October 13
  • 10. All in common: All small! All do one thing! Wednesday, 9 October 13
  • 11. Aside: FP (more later) Some services lend themselves to “purity” eg: Automatic scaling F(last minute stats) = recommendation to scale up, or down (or no change) No state, no persistence. Perfect candidate for FP. Wednesday, 9 October 13
  • 12. Why not monolithic? Can easily do @Produces(MediaType.JSON) @Path("/apps") @POST ... Thanks to jax-rs in one app? why not? Different endpoints via @Path, different methods, different classes? Wednesday, 9 October 13
  • 13. Why not monolithic? Apps grow (teams grow too!) Different parts change at different rates Different execution container needs (resources) Different teams? Company grows? But most of all: Wednesday, 9 October 13
  • 14. Why not monolithic? Fear. Risk. Fear of deploying a change. Risk of trying a new technique, new framework. Wednesday, 9 October 13
  • 15. Why not monolithic? Deploying a change to a microservice does not increase blood pressure as much as deploying the ONE MASSIVE APP THAT RUNS EVERYTHING Wednesday, 9 October 13
  • 17. Monolithic debugging (Often in production) ??? Wednesday, 9 October 13
  • 19. Shift to dev-ops More deployment expected More *people* doing the deployment Wednesday, 9 October 13
  • 20. Smooth deployment Microservices need: - easy rollback - no “over the wall” deployment - easy as-needed deployment - accessible deploy environment A PaaS can help (private or public) - they were born for this. Wednesday, 9 October 13
  • 21. Transport Typically (but not always) HTTP Typically (but not always) JSON (autoscale service was message bus + thrift name/ value pairs) But *are* always loosely coupled (ie never RMI) Wednesday, 9 October 13
  • 22. Containers Execution environment: - anything really - consumers of APIs don’t care - but developers do, deployers do - JVM ideal: enough controls/constraints - many languages - many frameworks If you had to pick one: JVM wins. Wednesday, 9 October 13
  • 23. Convinced? By this point I hope I have convinced you microservices are good. Right? Wednesday, 9 October 13
  • 25. Functional Programming with microservices First, some background... Wednesday, 9 October 13
  • 26. Context New Company New Team New Product You might not be this “lucky” Wednesday, 9 October 13
  • 27. History 2010 Started: JVM stack parts - Scala not controversial (I had experience) - working mostly “lone wolf” 2011 - another team added - brought Erlang Wednesday, 9 October 13
  • 29. More FP Given “success” with Scala, more FP (services, languages) was not viewed as a great risk. Wednesday, 9 October 13
  • 30. Observation FP means one person can do more && People like me like to work alone ∴ risk of staying with one-person-per micro service (is this a bad thing?) Wednesday, 9 October 13
  • 31. Objections and resistance Ask why: - resistance to the “new” (unnecessary risk) - resistance to FP ideas (hype?) - polyglot fear (realistically multiple languages will be used) Wednesday, 9 October 13
  • 32. Maintainability objection It goes: - how will anyone be able to maintain this after you? My Experience: - projects featuring FP handed over successfully - new developers able to pick up FP easily - seasoned developers too Wednesday, 9 October 13
  • 33. Where we may differ Small teams - many systems. ∴ Little overlap in jobs. We get to use a great PaaS ! (our own!) for all these micro services Wednesday, 9 October 13
  • 34. What did we do with FP Manage horrendous public cloud APIs Automatic scaling (microservice) Github crawling (microservice) Subscription/signup/entitlements (microservice) ... and microservices Wednesday, 9 October 13
  • 35. Surprisingly practical things No real calculations, no explicit maths. Just boring every day error prone stuff. Wednesday, 9 October 13
  • 37. Providore Evil cloud api Build masters build workers Workspace storage Wednesday, 9 October 13
  • 38. New build required. Check the pool, talk to the Evil api, ask for a new server, it fails, ask again. Wait for server to be up, no, I mean really up. Ask for a new disk, wait for a new disk, it fails, try again, attach the new disk, is the disk attached? fails, try again, damn it the snapshot isn’t available. The problem: Wednesday, 9 October 13
  • 39. How can we solve this? TDD? problems only manifest under load/in- production. APIs are buggy, change over time. Industry best practice: hack something together as a script and some of the time it works. Can FP help us? Wednesday, 9 October 13
  • 40. Yes Types (providore is written in scala) - Specifically: Option, Either - Closed Data Types (servers only in so many states) The M word: Monads Currying Wednesday, 9 October 13
  • 41. Cloud API launch_server: Server at best hopes to be: launch_server: Option[Server] launch_server: Either[Server, OhGodWhyWhyWhy] (not an actual pure function of course) Wednesday, 9 October 13
  • 42. Cloud Monad Cloud APIs are like IO Slow, horrible, misbehaving IO ...and then the APIs other people write All want to be monadic Wednesday, 9 October 13
  • 43. val validation: String / Subscription = (for { account <- extractAccount _ <- validateSubscription(account) callback <- extractCallBack plan <- validatePlan billing_day <- extractBillingDay subscription <- createSub(account, plan, callback, ... } yield subscription).run(req.body) (scala) ReaderT to help you compose http://debasishg.blogspot.com.au/2011/07/ monad-transformers-in-scala.html Need to “organise code in monadic way” Wednesday, 9 October 13
  • 44. Types So hard to catch things without them Monadic IO + types mean you catch things before you try Trying/experimenting can be $$ expensive... (still learning this, all new to me) Wednesday, 9 October 13
  • 45. Types helped with Ignored messages Bad pattern matching Misconfiguration/timing of server creation Avoiding “stringly typed” messages All “real world” things types have help us catch with a friendly compile error** ** may not actually be friendly Wednesday, 9 October 13
  • 46. Types didn’t help with... Wednesday, 9 October 13
  • 47. def ec2 Fog::Compute.new(:provider => 'AWS', :aws_secret_access_key => ENV['EC2_SECRET_KEY'], :aws_access_key_id => ENV['EC2_ACCESS_KEY']) end   def tenured? (instance) instance.created_at && (instance.created_at < Chronic.parse('50 minutes ago')) end   def alive? (instance) instance.state == 'running' or instance.state == 'stopped' end   zombies = ec2.servers.select { |i| i.tags.empty? && tenured?(i) && alive?(i) } Parallel.each(zombies, :in_threads => 15) do |zombie| begin puts "Terminating zombie node #{zombie.id}" ec2.servers.get(zombie.id).destroy end end Wednesday, 9 October 13
  • 49. Currying Server lifecycle: Reserved->Launching->Update (user data)->Volume Create->Volume Attach- >initialise/start Accumulate setup data via partial application Instead of an object that has mutating state, a function you partially apply to accumulate data. Good “beginner” FP concept (powerful, simple) Wednesday, 9 October 13
  • 50. Small things But every little bit helps. The pure FP is my ideal, rarely reached (so far) Wednesday, 9 October 13
  • 53. Auto scaling F(last minute stats, previous data window) -> “Suggestion” to scale up, or down (or in or out) Fundamentally calculation, fundamentally functional. Wednesday, 9 October 13
  • 54. Side effects Push out side effects to other side of the message bus Let a nasty app handle the side effects Messages are signals, suggestions, idempotent Wednesday, 9 October 13
  • 55. Advocating to Developers Don’t “sell” to your developers by: - saying monad too often - saying “it’s easy” - showing that it can be just as easy/familiar as what they have Instead... Wednesday, 9 October 13
  • 56. Find the functions Find the functions in what they do Find the calculations (eg core of autoscaling) Advanced: Separate the program definition from the execution (monads) Intermediate: Currying, Higher order functions, Types (good ones) Wednesday, 9 October 13
  • 57. ‘Unlearning’ OO Clojure: excellent at teaching people to forget about OO. Scala: challenge. Temptation always there. ∴ Use object/package as namespace (avoid classes) Aside: lack of implicit state allows “Erlang Magic” Wednesday, 9 October 13
  • 58. Some Frameworks for FP & Microservices Quick tour: Wednesday, 9 October 13
  • 59. Quick development for web apps and APIs RESTful by design “batteries included” - has everything. Easy reuse of all java libraries. www.playframework.com Wednesday, 9 October 13
  • 61. Easy deployment (jar/zip file) Can support DBs/evolution Excellent JSON/http/web support Security, Async, Background jobs, and more Scala or Java. Wednesday, 9 October 13
  • 62. Compojure: just enough web framework Light - small apps Deploy as war, or embedded jetty Great libraries, reuse java libs Effortless JSON -> clojure https://github.com/weavejester/compojure Wednesday, 9 October 13
  • 64. (:use cheshire.core) (let [clojure-data (parse-string json-data)]) (generate-string clojure-data) ;;magic! https://github.com/dakrone/cheshire Wednesday, 9 October 13
  • 65. To the Cloud! Want to try things at your company: Cloud Platforms (hint! vendor shilling!) make it easy to try things out that may be used seriously. Clojure anywhere, Scala anywhere Say “cloud cloud” a lot and people will listen. Wednesday, 9 October 13
  • 66. Mixed language projects Good idea?? Relevant to JVM Ease-into-it Jury is out... Wednesday, 9 October 13
  • 67. Bad questions to hear (when advocating) If you hear these asked, probably will have a bad time: How will we hire people? Does it work for large teams? Wednesday, 9 October 13
  • 68. Final Observation Developers who have fondness for emacs/vim (over IDE) find things easier FP invites “change this small bit, see what happens” exploration No real tool barriers. If I can do this, anyone can. Wednesday, 9 October 13
  • 69. Conclusion FP and Microservices *naturally* go together Can be about Risk Reduction in new rapid deployment world Cloud A good place to try FP Wednesday, 9 October 13