SlideShare a Scribd company logo
Patterns and Practices for
Real-world, Event-driven
Microservices
Rachel Reese | @rachelreese | rachelree.se
Jet Technology | @JetTechnology | tech.jet.com
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
jet-microservices-cloud
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Real-world
We plan to be the new Amazon.com
Launched July 22, 2015
• Both Apple & Android named our app
as one of their tops for 2015
• Over 20k orders per day
• Over 10.5 million SKUs
• #4 marketplace worldwide
• 700 microservices
Stop by the power-up lounge!
Azure Web sites
Cloud
services VMs Service bus
queues
Services
bus topics
Blob storage
Table
storage Queues Hadoop DNS Active
directory
SQL Azure R
F# Paket FSharp.Data Chessie Unquote SQLProvider Python
Deedle FAKE FSharp.Async React Node Angular SAS
Storm Elastic
Search
Xamarin Microservices Consul Kafka PDW
Splunk Redis SQL Puppet Jenkins
Apache
Hive
Apache
Tez
Microservices
Microservices
An application of the single responsibility principle at the service level.
Has an input, produces an output.
Easy scalability
Independent releasability
More even distribution of complexity
Benefits
“A class should have one, and only one, reason to change.”
Event-driven
Event-driven
The focus of your
application code is to react to
events (single or a stream).
Events
Any significant change in
state that has happened
in your domain
Past tense
Immutable
Contains only relevant
data to transaction
All events should be represented as
verbs in the past tense such as
CustomerRelocated,
CargoShipped, or
InventoryLossageRecorded.
For those who speak French, it should be
passé composé, they are things that have
completed in the past.
Greg Young
Event
Consumer
“Events” as the notification messages
Event channelEvent
Emitter
Event-sourced
Compare to relational
model which captures
only the latest state
change. These sets
are then related to
each other.
Event-sourced
• Event-sourced is about how you model the domain.
• An append-only sequence of events as data store.
• Keep track of all state changes.
• Can REPLAY these event streams.
Event Stream
How did Jet decide on microservices?
Why F#?
Patterns & Practices for Cloud-based Microservices
Why F#? <3
FP |> Programmers <3
Why F#? Productivity
The F# solution offers us an order of magnitude
increase in productivity and allows one developer to
perform the work [of] a team of dedicated
developers…
Yan Cui
Lead Server Engineer, Gamesys
“
“ “
Why F#? Expanded feature set
Expanded feature set: Option types
Expanded feature set: Discriminated unions
public abstract class Transport{ }
public abstract class Car : Transport {
public string Make { get; private set; }
public string Model { get; private set; }
public Car (string make, string model) {
this.Make = make;
this.Model = model;
}
}
public abstract class Bus : Transport {
public int Route { get; private set; }
public Bus (int route) {
this.Route = route;
}
}
public class Bicycle: Transport {
public Bicycle() {
}
}
type Transport =
| Car of Make:string * Model:string
| Bus of Route:int
| Bicycle
C# F#
Trivial to pattern match on!
F#patternmatching
C#
Concise & powerful code
public abstract class Transport{ }
public abstract class Car : Transport {
public string Make { get; private set; }
public string Model { get; private set; }
public Car (string make, string model) {
this.Make = make;
this.Model = model;
}
}
public abstract class Bus : Transport {
public int Route { get; private set; }
public Bus (int route) {
this.Route = route;
}
}
public class Bicycle: Transport {
public Bicycle() {
}
}
type Transport =
| Car of Make:string * Model:string
| Bus of Route:int
| Bicycle
| Train of Line:int
let getThereVia (transport:Transport) =
match transport with
| Car (make,model) -> ...
| Bus route -> ...
| Bicycle -> ...
Warning FS0025: Incomplete pattern
matches on this expression. For example,
the value ’Train' may indicate a case not
covered by the pattern(s)
C# F#
Expanded feature set: Type providers
920
pages!
31 lines!
Why F#? Readability
Readability!
Patterns & Practices for Cloud-based Microservices
type Booking =
| Basic of Plane
| Combo of Combo
| FullPack of Plane * Hotel * Car
and Plane = {Outbound: DateTime; Return: DateTime; Destination: Country}
and Combo =
| ``With Hotel`` of Plane * Hotel
| ``With Car`` of Plane * Car
and Hotel = {Arrival: DateTime; Departure: DateTime; Location: Country}
and Car = {From: DateTime; To: DateTime; Location: Country}
and Country = {Name: String; ``ISO 3166-1``: char*char}
Patterns & Practices for Cloud-based Microservices
Original code
Refactored, clean code
F# way 37
type Year = int
type [<Measure>] percent
type Customer = Simple | Valuable | MostValuable
type AccountStatus =
| Registered of Customer * since:Year
| Unregistered
let customerDiscount = function
| Simple -> 1<percent>
| Valuable -> 3<percent>
| MostValuable -> 5<percent>
let yearsDiscount = function
| years when years > 5 -> 5<percent>
| years -> 1<percent> * years
let accountDiscount = function
| Registered (customer, years) ->
customerDiscount customer, yearsDiscount years
| Unregistered -> 0<percent>, 0<percent>
let asPercent p = decimal p / 100m
let reducePriceBy discount price =
price - price * (asPercent discount)
let calculateDiscountedPrice price account =
let custDiscount, yrsDiscount =
accountDiscount account
price
|> reducePriceBy custDiscount
|> reducePriceBy yrsDiscount
Why F#? You don’t need a Ph.D.
This is Sean.
When Sean was 8, he started speaking at large
technical conferences. On F#.
Guidelines
Be functional!
Prefer immutability
Avoid state changes,
side effects, and
mutable data
Use data in  data out
transformations
Think about mapping inputs
to outputs.
Look at problems
recursively
Consider successively
smaller chunks of the
same problem
Treat functions as
unit of work
Higher-order functions
Don’t abstract
This one magical service could write to ALL of the following:
…badly.
Event
store
Nservice
Bus
MSMQ 0MQ
SQL
Server
Isolate side effects
Submit order
microservice
Insert order to
SQL microservice
Send thank you
email microservice
Updates SQL
Sends “Thank you for
ordering” Email
Updates SQL
Sends “Thank you for
ordering” Email
Use a backup service to replay events
Service 1 runs in production as normal
Backup service 1 replays events until up-to-date.
Switch over. Instantly live with changes!
Also stage a copy of any aggregate/data store
until stream has completed replaying!
type Input =
| Product of Product
type Output =
| ProductPriceNile of Product * decimal
| ProductPriceCheckFailed of PriceCheckFailed
let handle (input:Input) =
async {
return Some(ProductPriceNile({Sku="343434"; ProductId = 17; ProductDescription = "My
amazing product"; CostPer=1.96M}, 3.96M))
}
let interpret id output =
match output with
| Some (Output.ProductPriceNile (e, price)) -> async {()} // write to event store
| Some (Output.ProductPriceCheckFailed e) -> async {()} // log failure
| None -> async {{ }} // log failure
let consume = EventStoreQueue.consume (decodeT Input.Product) handle interpret
What do our services look like?
Define inputs
& outputs
Define how input
transforms to output
Define what to do
with output
Read events,
handle, & interpret
Microservices should not control own lifecycle
Execution
runtime
Deployment Configuration Restarting
Versioning Scaling Availability
Grouping by
subsystem
Scheduling
Input-output
static analysis
Dashboard
Think
IoC!
Torch YAML files
torchVer: 2.0.0
subSystem: PriceCheck
name: PriceCheck
description: checks prices on nile
ver: 0.0.1
autoStart: always
compile: true
ha: aa ##active-active. Could be ap for active-passive
scriptPath: PriceCheckNilePriceCheckNile.fsx
libPath: binrelease
args: --jsonConfig=PriceCheckNile.json
It used to mean “Yet Another Markup Language” but was backronymed to clarify its focus as data-oriented.
YAML = “YAML Ain’t Markup Language”
Summary
Don’t
abstract
Be
functional
Isolate side
effects
Use a backup
service
Use consistent
formatting
Use an outside
product to control
lifecycle
For more information 51
F#
fsharp.org
fsharpforfunandprofit.com
NYC F# & Jet Tech Meetup
Event sourcing
Greg Young talks:
http://www.infoq.com/news/2014/09/greg-young-event-sourcing
https://www.youtube.com/watch?v=JHGkaShoyNs
Microservices
martinfowler.com
microservices.io
Patterns and Practices for
Real-world, Event-driven
Microservices
Rachel Reese | @rachelreese | rachelree.se
Jet Technology | @JetTechnology | tech.jet.com
Watch the video with slide synchronization on
InfoQ.com!
https://www.infoq.com/presentations/jet-
microservices-cloud

More Related Content

PDF
Patterns & Practices of Microservices
PDF
Dell and KEMP - Partnering for scale
PPTX
Pros & Cons of Microservices Architecture
PDF
Building a Bank out of Microservices (NDC Sydney, August 2016)
PPTX
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
PDF
Scalable Microservices at Netflix. Challenges and Tools of the Trade
PDF
12 Factor Serverless Applications - Mike Morain, AWS - Cloud Native Day Tel A...
PDF
Cloud-native Data
Patterns & Practices of Microservices
Dell and KEMP - Partnering for scale
Pros & Cons of Microservices Architecture
Building a Bank out of Microservices (NDC Sydney, August 2016)
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
Scalable Microservices at Netflix. Challenges and Tools of the Trade
12 Factor Serverless Applications - Mike Morain, AWS - Cloud Native Day Tel A...
Cloud-native Data

What's hot (15)

PDF
JCConf.tw 2020 - Building cloud-native applications with Quarkus
PPTX
Oracle Code Keynote with Thomas Kurian
PPTX
Delivering Developer Tools at Scale
PDF
locize tech stack
PPTX
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
PDF
eBay Architecture
PDF
It’s Not Just Request/Response: Understanding Event-driven Microservices
PDF
Building a Modern Microservices Architecture at Gilt: The Essentials
PDF
CQRS and Event Sourcing
PPTX
Modernizing the Legacy - How Dish is Adapting its SOA Services for a Cloud Fi...
PDF
Distributed Design and Architecture of Cloud Foundry
PPTX
Mastering Chaos - A Netflix Guide to Microservices
PPTX
Java micro-services
PPTX
Microservices architecture
PDF
Building Serverless Apps with Kafka (Dale Lane, IBM) Kafka Summit London 2019
JCConf.tw 2020 - Building cloud-native applications with Quarkus
Oracle Code Keynote with Thomas Kurian
Delivering Developer Tools at Scale
locize tech stack
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
eBay Architecture
It’s Not Just Request/Response: Understanding Event-driven Microservices
Building a Modern Microservices Architecture at Gilt: The Essentials
CQRS and Event Sourcing
Modernizing the Legacy - How Dish is Adapting its SOA Services for a Cloud Fi...
Distributed Design and Architecture of Cloud Foundry
Mastering Chaos - A Netflix Guide to Microservices
Java micro-services
Microservices architecture
Building Serverless Apps with Kafka (Dale Lane, IBM) Kafka Summit London 2019

Viewers also liked (6)

PPTX
Graph Database workshop
PPTX
Service Fabric – building tomorrows applications today
PPTX
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
PPTX
Devteach 2016: A practical overview of actors in service fabric
PDF
Microservice architecture at ASOS
PDF
5 must-have patterns for your microservice - buildstuff
Graph Database workshop
Service Fabric – building tomorrows applications today
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Devteach 2016: A practical overview of actors in service fabric
Microservice architecture at ASOS
5 must-have patterns for your microservice - buildstuff

Similar to Patterns & Practices for Cloud-based Microservices (20)

PPTX
Patterns and practices for real-world event-driven microservices
PPTX
Patterns and practices for real-world event-driven microservices by Rachel Re...
PDF
Microservices Chaos Testing at Jet
PDF
Event Driven-Architecture from a Scalability perspective
KEY
Event Driven Architecture
PPTX
Patterns of Distributed Application Design
PDF
Patterns of Distributed Application Design
PPTX
Using Event Streams in Serverless Applications
PPTX
Events & Microservices
PPTX
Microservices with .Net - NDC Sydney, 2016
PDF
fundamentalsofeventdrivenmicroservices11728489736099.pdf
PPTX
Chaos Testing with F# and Azure by Rachel Reese at Codemotion Dubai
PDF
Events and microservices
PPTX
Event Driven Microservices architecture
PDF
Building Event Driven (Micro)services with Apache Kafka
PDF
Design Microservice Architectures the Right Way
PPTX
Architecting Microservices in .Net
PDF
20220311-EB-Designing_Event_Driven_Systems.pdf
PDF
Designing Events-first Microservices
PDF
Building Event Driven (Micro)services with Apache Kafka
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservices by Rachel Re...
Microservices Chaos Testing at Jet
Event Driven-Architecture from a Scalability perspective
Event Driven Architecture
Patterns of Distributed Application Design
Patterns of Distributed Application Design
Using Event Streams in Serverless Applications
Events & Microservices
Microservices with .Net - NDC Sydney, 2016
fundamentalsofeventdrivenmicroservices11728489736099.pdf
Chaos Testing with F# and Azure by Rachel Reese at Codemotion Dubai
Events and microservices
Event Driven Microservices architecture
Building Event Driven (Micro)services with Apache Kafka
Design Microservice Architectures the Right Way
Architecting Microservices in .Net
20220311-EB-Designing_Event_Driven_Systems.pdf
Designing Events-first Microservices
Building Event Driven (Micro)services with Apache Kafka

More from C4Media (20)

PDF
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
PDF
Next Generation Client APIs in Envoy Mobile
PDF
Software Teams and Teamwork Trends Report Q1 2020
PDF
Understand the Trade-offs Using Compilers for Java Applications
PDF
Kafka Needs No Keeper
PDF
High Performing Teams Act Like Owners
PDF
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
PDF
Service Meshes- The Ultimate Guide
PDF
Shifting Left with Cloud Native CI/CD
PDF
CI/CD for Machine Learning
PDF
Fault Tolerance at Speed
PDF
Architectures That Scale Deep - Regaining Control in Deep Systems
PDF
ML in the Browser: Interactive Experiences with Tensorflow.js
PDF
Build Your Own WebAssembly Compiler
PDF
User & Device Identity for Microservices @ Netflix Scale
PDF
Scaling Patterns for Netflix's Edge
PDF
Make Your Electron App Feel at Home Everywhere
PDF
The Talk You've Been Await-ing For
PDF
Future of Data Engineering
PDF
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Next Generation Client APIs in Envoy Mobile
Software Teams and Teamwork Trends Report Q1 2020
Understand the Trade-offs Using Compilers for Java Applications
Kafka Needs No Keeper
High Performing Teams Act Like Owners
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Service Meshes- The Ultimate Guide
Shifting Left with Cloud Native CI/CD
CI/CD for Machine Learning
Fault Tolerance at Speed
Architectures That Scale Deep - Regaining Control in Deep Systems
ML in the Browser: Interactive Experiences with Tensorflow.js
Build Your Own WebAssembly Compiler
User & Device Identity for Microservices @ Netflix Scale
Scaling Patterns for Netflix's Edge
Make Your Electron App Feel at Home Everywhere
The Talk You've Been Await-ing For
Future of Data Engineering
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Electronic commerce courselecture one. Pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Patterns & Practices for Cloud-based Microservices

  • 1. Patterns and Practices for Real-world, Event-driven Microservices Rachel Reese | @rachelreese | rachelree.se Jet Technology | @JetTechnology | tech.jet.com
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ jet-microservices-cloud
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 5. We plan to be the new Amazon.com Launched July 22, 2015 • Both Apple & Android named our app as one of their tops for 2015 • Over 20k orders per day • Over 10.5 million SKUs • #4 marketplace worldwide • 700 microservices Stop by the power-up lounge!
  • 6. Azure Web sites Cloud services VMs Service bus queues Services bus topics Blob storage Table storage Queues Hadoop DNS Active directory SQL Azure R F# Paket FSharp.Data Chessie Unquote SQLProvider Python Deedle FAKE FSharp.Async React Node Angular SAS Storm Elastic Search Xamarin Microservices Consul Kafka PDW Splunk Redis SQL Puppet Jenkins Apache Hive Apache Tez
  • 8. Microservices An application of the single responsibility principle at the service level. Has an input, produces an output. Easy scalability Independent releasability More even distribution of complexity Benefits “A class should have one, and only one, reason to change.”
  • 10. Event-driven The focus of your application code is to react to events (single or a stream).
  • 11. Events Any significant change in state that has happened in your domain Past tense Immutable Contains only relevant data to transaction All events should be represented as verbs in the past tense such as CustomerRelocated, CargoShipped, or InventoryLossageRecorded. For those who speak French, it should be passé composé, they are things that have completed in the past. Greg Young
  • 12. Event Consumer “Events” as the notification messages Event channelEvent Emitter
  • 14. Compare to relational model which captures only the latest state change. These sets are then related to each other. Event-sourced • Event-sourced is about how you model the domain. • An append-only sequence of events as data store. • Keep track of all state changes. • Can REPLAY these event streams.
  • 16. How did Jet decide on microservices?
  • 22. The F# solution offers us an order of magnitude increase in productivity and allows one developer to perform the work [of] a team of dedicated developers… Yan Cui Lead Server Engineer, Gamesys “ “ “
  • 23. Why F#? Expanded feature set
  • 24. Expanded feature set: Option types
  • 25. Expanded feature set: Discriminated unions public abstract class Transport{ } public abstract class Car : Transport { public string Make { get; private set; } public string Model { get; private set; } public Car (string make, string model) { this.Make = make; this.Model = model; } } public abstract class Bus : Transport { public int Route { get; private set; } public Bus (int route) { this.Route = route; } } public class Bicycle: Transport { public Bicycle() { } } type Transport = | Car of Make:string * Model:string | Bus of Route:int | Bicycle C# F# Trivial to pattern match on!
  • 27. Concise & powerful code public abstract class Transport{ } public abstract class Car : Transport { public string Make { get; private set; } public string Model { get; private set; } public Car (string make, string model) { this.Make = make; this.Model = model; } } public abstract class Bus : Transport { public int Route { get; private set; } public Bus (int route) { this.Route = route; } } public class Bicycle: Transport { public Bicycle() { } } type Transport = | Car of Make:string * Model:string | Bus of Route:int | Bicycle | Train of Line:int let getThereVia (transport:Transport) = match transport with | Car (make,model) -> ... | Bus route -> ... | Bicycle -> ... Warning FS0025: Incomplete pattern matches on this expression. For example, the value ’Train' may indicate a case not covered by the pattern(s) C# F#
  • 28. Expanded feature set: Type providers 920 pages! 31 lines!
  • 32. type Booking = | Basic of Plane | Combo of Combo | FullPack of Plane * Hotel * Car and Plane = {Outbound: DateTime; Return: DateTime; Destination: Country} and Combo = | ``With Hotel`` of Plane * Hotel | ``With Car`` of Plane * Car and Hotel = {Arrival: DateTime; Departure: DateTime; Location: Country} and Car = {From: DateTime; To: DateTime; Location: Country} and Country = {Name: String; ``ISO 3166-1``: char*char}
  • 36. F# way 37 type Year = int type [<Measure>] percent type Customer = Simple | Valuable | MostValuable type AccountStatus = | Registered of Customer * since:Year | Unregistered let customerDiscount = function | Simple -> 1<percent> | Valuable -> 3<percent> | MostValuable -> 5<percent> let yearsDiscount = function | years when years > 5 -> 5<percent> | years -> 1<percent> * years let accountDiscount = function | Registered (customer, years) -> customerDiscount customer, yearsDiscount years | Unregistered -> 0<percent>, 0<percent> let asPercent p = decimal p / 100m let reducePriceBy discount price = price - price * (asPercent discount) let calculateDiscountedPrice price account = let custDiscount, yrsDiscount = accountDiscount account price |> reducePriceBy custDiscount |> reducePriceBy yrsDiscount
  • 37. Why F#? You don’t need a Ph.D.
  • 39. When Sean was 8, he started speaking at large technical conferences. On F#.
  • 41. Be functional! Prefer immutability Avoid state changes, side effects, and mutable data Use data in  data out transformations Think about mapping inputs to outputs. Look at problems recursively Consider successively smaller chunks of the same problem Treat functions as unit of work Higher-order functions
  • 42. Don’t abstract This one magical service could write to ALL of the following: …badly. Event store Nservice Bus MSMQ 0MQ SQL Server
  • 43. Isolate side effects Submit order microservice Insert order to SQL microservice Send thank you email microservice Updates SQL Sends “Thank you for ordering” Email Updates SQL Sends “Thank you for ordering” Email
  • 44. Use a backup service to replay events Service 1 runs in production as normal Backup service 1 replays events until up-to-date. Switch over. Instantly live with changes! Also stage a copy of any aggregate/data store until stream has completed replaying!
  • 45. type Input = | Product of Product type Output = | ProductPriceNile of Product * decimal | ProductPriceCheckFailed of PriceCheckFailed let handle (input:Input) = async { return Some(ProductPriceNile({Sku="343434"; ProductId = 17; ProductDescription = "My amazing product"; CostPer=1.96M}, 3.96M)) } let interpret id output = match output with | Some (Output.ProductPriceNile (e, price)) -> async {()} // write to event store | Some (Output.ProductPriceCheckFailed e) -> async {()} // log failure | None -> async {{ }} // log failure let consume = EventStoreQueue.consume (decodeT Input.Product) handle interpret What do our services look like? Define inputs & outputs Define how input transforms to output Define what to do with output Read events, handle, & interpret
  • 46. Microservices should not control own lifecycle Execution runtime Deployment Configuration Restarting Versioning Scaling Availability Grouping by subsystem Scheduling Input-output static analysis Dashboard Think IoC!
  • 47. Torch YAML files torchVer: 2.0.0 subSystem: PriceCheck name: PriceCheck description: checks prices on nile ver: 0.0.1 autoStart: always compile: true ha: aa ##active-active. Could be ap for active-passive scriptPath: PriceCheckNilePriceCheckNile.fsx libPath: binrelease args: --jsonConfig=PriceCheckNile.json It used to mean “Yet Another Markup Language” but was backronymed to clarify its focus as data-oriented. YAML = “YAML Ain’t Markup Language”
  • 48. Summary Don’t abstract Be functional Isolate side effects Use a backup service Use consistent formatting Use an outside product to control lifecycle
  • 49. For more information 51 F# fsharp.org fsharpforfunandprofit.com NYC F# & Jet Tech Meetup Event sourcing Greg Young talks: http://www.infoq.com/news/2014/09/greg-young-event-sourcing https://www.youtube.com/watch?v=JHGkaShoyNs Microservices martinfowler.com microservices.io
  • 50. Patterns and Practices for Real-world, Event-driven Microservices Rachel Reese | @rachelreese | rachelree.se Jet Technology | @JetTechnology | tech.jet.com
  • 51. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/jet- microservices-cloud