SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Chaos Engineering at Jet.com
Rachel Reese | @rachelreese | rachelree.se
Jet Technology | @JetTechnology | tech.jet.com
Why do you need chaos testing?
The world is naturally chaotic
But do we need more testing?
Unit Sanity Random Continuous
UsabilityA/BLocalizationAcceptance
Regression Performance Integration Security
You’ve already tested all your
components in multiple ways.
It’s super important to test the interactions in your
environment
Jet? Jet who?
We plan to be the new Amazon.com
Launched July 22, 2015
• Both Apple & Android named our app
as one of their top 5 for 2015
• Over 20k orders per day
• Over 10.5 million SKUs
• #4 marketplace worldwide
• 700 microservices
We’re hiring!
http://jet.com/about-us/working-at-jet
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
FAK
E
FSharp.Async React Node Angular SAS
Storm Elastic
Search
Xamarin Microservices Consul Kafka PDW
Splunk Redis SQL Puppet Jenkins
Apache
Hive
Apache
Tez
What is chaos engineering?
It’s just wreaking havoc with your code
for fun, right?
Chaos Engineering is…
Controlled experiments on a distributed system
that help you build confidence in the system’s
ability to tolerate the inevitable failures.
Principles of Chaos Engineering
1. Define “normal”
2. Assume ”normal” will continue in both a control group
and an experimental group.
3. Introduce chaos: servers that crash, hard drives that
malfunction, network connections that are severed, etc.
4. Look for a difference in behavior between the control
group and the experimental group.
Going farther
Build a Hypothesis around Normal Behavior
Vary Real-world Events
Run Experiments in Production
Automate Experiments to Run Continuously
From http://principlesofchaos.org/
Benefits of chaos engineering
Benefits of chaos engineering
You're awake Design for failure
Healthy systems Self service
Current examples of chaos engineering
Maybe you meant Netflix’s Chaos Monkey?
How is Jet different?
We’re not testing in prod (yet).
SQL restarts & geo-replication
Start
- Checks the source db for write access
- Renames db on destination server (to create a new one)
- Creates a geo-replication in the destination region
Stop
- Shuts down cloud services writing to source db
- Sets source db as read-only
- Ends continuous copy
- Allows writes to secondary db
Azure & F#
Why F#?
I have now delivered three business critical projects
written in F#. I am still waiting for the first bug to
come in.
Simon Cousins
UK Power company
“
“ “
Concise and 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
C# F#
Trivial to pattern match on!
F#patternmatching
C#
Concise and 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#
Units of Measure
Expanded feature set: Type providers
920 pages!
31 lines!
TickSpec – an F# project
Thanks to Scott Wlaschin for his post, Cycles and modularity in the wild
SpecFlow– a comparable C# project
Thanks to Scott Wlaschin for his post, Cycles and modularity in the wild
Entity Framework (C#)
Thanks to Scott Wlaschin for his post, Cycles and modularity in the wild
Chaos code!
Our code!
let selectRandomInstance compute hostedService = async {
try
let! details = getHostedServiceDetails compute hostedService.ServiceName
let deployment = getProductionDeployment details
let instance = deployment.RoleInstances
|> Seq.toArray
|> randomPick
return details.ServiceName, deployment.Name, instance
with e ->
log.error "Failed selecting random instancen%A" e
reraise e
}
Our code!
let restartRandomInstance compute hostedService = async {
try
let! serviceName, deploymentId, roleInstance =
selectRandomInstance compute hostedService
match roleInstance.PowerState with
| RoleInstancePowerState.Stopped ->
log.info "Service=%s Instance=%s is stopped...ignoring...”
serviceName roleInstance.InstanceName
| _ ->
do! restartInstance compute serviceName deploymentId roleInstance.InstanceName
with e ->
log.error "%s" e.Message
}
Our code!
compute
|> getHostedServices
|> Seq.filter ignoreList
|> knuthShuffle
|> Seq.distinctBy (fun a -> a.ServiceName)
|> Seq.map (fun hostedService -> async {
try
return! restartRandomInstance compute hostedService
with
e -> log.warn "failed: service=%s . %A" hostedService.ServiceName e
return ()
})
|> Async.ParallelIgnore 1
|> Async.RunSynchronously
Has it helped?
Elasticsearch restart
Additional chaos finds
- Redis
- Checkpointing
If availability matters, you should be
testing for it.
Azure + F# + Chaos = <3
Chaos Engineering at Jet.com
Rachel Reese | @rachelreese | rachelree.se
Jet Technology | @JetTechnology | tech.jet.com

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (12)

20190406 LT(笹亀)
20190406 LT(笹亀)20190406 LT(笹亀)
20190406 LT(笹亀)
 
Runtime performance
Runtime performanceRuntime performance
Runtime performance
 
Presentation kyushu-2018
Presentation kyushu-2018Presentation kyushu-2018
Presentation kyushu-2018
 
10 minute command line apps with zio cli
10 minute command line apps with zio cli10 minute command line apps with zio cli
10 minute command line apps with zio cli
 
Intuitive CLIs for gRPC APIs
Intuitive CLIs for gRPC APIsIntuitive CLIs for gRPC APIs
Intuitive CLIs for gRPC APIs
 
Creating a modern web application using Symfony API Platform Atlanta
Creating a modern web application using  Symfony API Platform AtlantaCreating a modern web application using  Symfony API Platform Atlanta
Creating a modern web application using Symfony API Platform Atlanta
 
Bucketlist travel app
Bucketlist travel appBucketlist travel app
Bucketlist travel app
 
Embulk at Treasure Data
Embulk at Treasure DataEmbulk at Treasure Data
Embulk at Treasure Data
 
Aws Patterns
Aws PatternsAws Patterns
Aws Patterns
 
Idiomatic Kotlin for Android
Idiomatic Kotlin for AndroidIdiomatic Kotlin for Android
Idiomatic Kotlin for Android
 
Rubyon Rails
Rubyon RailsRubyon Rails
Rubyon Rails
 
inline function
inline function inline function
inline function
 

Ähnlich wie Chaos Testing with F# and Azure by Rachel Reese at Codemotion Dubai

Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the rest
george.james
 

Ähnlich wie Chaos Testing with F# and Azure by Rachel Reese at Codemotion Dubai (20)

Patterns and practices for real-world event-driven microservices by Rachel Re...
Patterns and practices for real-world event-driven microservices by Rachel Re...Patterns and practices for real-world event-driven microservices by Rachel Re...
Patterns and practices for real-world event-driven microservices by Rachel Re...
 
Patterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesPatterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based Microservices
 
C# Client to Cloud
C# Client to CloudC# Client to Cloud
C# Client to Cloud
 
Microservices Chaos Testing at Jet
Microservices Chaos Testing at JetMicroservices Chaos Testing at Jet
Microservices Chaos Testing at Jet
 
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
Davide Cerbo - Kotlin loves React - Codemotion Milan 2018
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDays
 
Fighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with EmbulkFighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with Embulk
 
"Frameworks in 2015" Андрей Листочкин
"Frameworks in 2015" Андрей Листочкин"Frameworks in 2015" Андрей Листочкин
"Frameworks in 2015" Андрей Листочкин
 
Advanced Model Inferencing leveraging Kubeflow Serving, KNative and Istio
Advanced Model Inferencing leveraging Kubeflow Serving, KNative and IstioAdvanced Model Inferencing leveraging Kubeflow Serving, KNative and Istio
Advanced Model Inferencing leveraging Kubeflow Serving, KNative and Istio
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenches
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the rest
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and PatternsMike Taulty MIX10 Silverlight Frameworks and Patterns
Mike Taulty MIX10 Silverlight Frameworks and Patterns
 
Dystopia as a Service
Dystopia as a ServiceDystopia as a Service
Dystopia as a Service
 
AWS re:Invent 2016: Building a Platform for Collaborative Scientific Research...
AWS re:Invent 2016: Building a Platform for Collaborative Scientific Research...AWS re:Invent 2016: Building a Platform for Collaborative Scientific Research...
AWS re:Invent 2016: Building a Platform for Collaborative Scientific Research...
 
Best Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data LayersBest Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data Layers
 
Hybrid Cloud, Kubeflow and Tensorflow Extended [TFX]
Hybrid Cloud, Kubeflow and Tensorflow Extended [TFX]Hybrid Cloud, Kubeflow and Tensorflow Extended [TFX]
Hybrid Cloud, Kubeflow and Tensorflow Extended [TFX]
 
Sadiq786
Sadiq786Sadiq786
Sadiq786
 

Mehr von Codemotion Dubai

Mehr von Codemotion Dubai (10)

Embrace chatOps, stop installing deployment software by Geshan Manandhar at C...
Embrace chatOps, stop installing deployment software by Geshan Manandhar at C...Embrace chatOps, stop installing deployment software by Geshan Manandhar at C...
Embrace chatOps, stop installing deployment software by Geshan Manandhar at C...
 
SMACK Stack - Fast Data Done Right by Stefan Siprell at Codemotion Dubai
SMACK Stack - Fast Data Done Right by Stefan Siprell at Codemotion DubaiSMACK Stack - Fast Data Done Right by Stefan Siprell at Codemotion Dubai
SMACK Stack - Fast Data Done Right by Stefan Siprell at Codemotion Dubai
 
Microservices for Mortals by Bert Ertman at Codemotion Dubai
 Microservices for Mortals by Bert Ertman at Codemotion Dubai Microservices for Mortals by Bert Ertman at Codemotion Dubai
Microservices for Mortals by Bert Ertman at Codemotion Dubai
 
Dockerize it: stop living in the past and embrace the future by Alex Nadalin
 Dockerize it: stop living in the past and embrace the future by Alex Nadalin Dockerize it: stop living in the past and embrace the future by Alex Nadalin
Dockerize it: stop living in the past and embrace the future by Alex Nadalin
 
Modelling complex game economy with Neo4j by Yan Cui at Codemotion Dubai
Modelling complex game economy with Neo4j by Yan Cui at Codemotion DubaiModelling complex game economy with Neo4j by Yan Cui at Codemotion Dubai
Modelling complex game economy with Neo4j by Yan Cui at Codemotion Dubai
 
Getting Developers hooked on your API by Nicolas Garnier at Codemotion Dubai
Getting Developers hooked on your API by Nicolas Garnier at Codemotion DubaiGetting Developers hooked on your API by Nicolas Garnier at Codemotion Dubai
Getting Developers hooked on your API by Nicolas Garnier at Codemotion Dubai
 
F# in social gaming by Yan Cui at Codemotion Dubai
F# in social gaming by Yan Cui at Codemotion DubaiF# in social gaming by Yan Cui at Codemotion Dubai
F# in social gaming by Yan Cui at Codemotion Dubai
 
Building event driven serverless apps by Danilo Poccia at Codemotion Dubai
Building event driven serverless apps by Danilo Poccia at Codemotion DubaiBuilding event driven serverless apps by Danilo Poccia at Codemotion Dubai
Building event driven serverless apps by Danilo Poccia at Codemotion Dubai
 
Javascript leverage: Isomorphic Applications by Luciano Colosio at Codemotion...
Javascript leverage: Isomorphic Applications by Luciano Colosio at Codemotion...Javascript leverage: Isomorphic Applications by Luciano Colosio at Codemotion...
Javascript leverage: Isomorphic Applications by Luciano Colosio at Codemotion...
 
Demystifying the 3D Web by Pietro Grandi @ Codemotion Dubai 2016
Demystifying the 3D Web by Pietro Grandi @ Codemotion Dubai 2016Demystifying the 3D Web by Pietro Grandi @ Codemotion Dubai 2016
Demystifying the 3D Web by Pietro Grandi @ Codemotion Dubai 2016
 

Kürzlich hochgeladen

怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
eeanqy
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
mark11275
 
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
yhavx
 
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman MuscatAbortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion pills in Kuwait Cytotec pills in Kuwait
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
wpkuukw
 
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
wpkuukw
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
eeanqy
 
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
drmarathore
 
Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...
Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...
Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...
ZurliaSoop
 
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
CristineGraceAcuyan
 

Kürzlich hochgeladen (20)

怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
 
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime PondicherryPondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
 
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best ServiceHigh Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
 
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
 
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
 
Mohanlalganj ! Call Girls in Lucknow - 450+ Call Girl Cash Payment 9548273370...
Mohanlalganj ! Call Girls in Lucknow - 450+ Call Girl Cash Payment 9548273370...Mohanlalganj ! Call Girls in Lucknow - 450+ Call Girl Cash Payment 9548273370...
Mohanlalganj ! Call Girls in Lucknow - 450+ Call Girl Cash Payment 9548273370...
 
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman MuscatAbortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
 
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
 
How to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfHow to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdf
 
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 
Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...
Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...
Jual Obat Aborsi Bandung ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan ...
 
Gamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad IbrahimGamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad Ibrahim
 
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best ServiceIndependent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
 
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
 

Chaos Testing with F# and Azure by Rachel Reese at Codemotion Dubai

  • 1. Chaos Engineering at Jet.com Rachel Reese | @rachelreese | rachelree.se Jet Technology | @JetTechnology | tech.jet.com
  • 2. Why do you need chaos testing?
  • 3. The world is naturally chaotic
  • 4. But do we need more testing? Unit Sanity Random Continuous UsabilityA/BLocalizationAcceptance Regression Performance Integration Security
  • 5. You’ve already tested all your components in multiple ways.
  • 6.
  • 7. It’s super important to test the interactions in your environment
  • 9. We plan to be the new Amazon.com Launched July 22, 2015 • Both Apple & Android named our app as one of their top 5 for 2015 • Over 20k orders per day • Over 10.5 million SKUs • #4 marketplace worldwide • 700 microservices We’re hiring! http://jet.com/about-us/working-at-jet
  • 10. 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 FAK E FSharp.Async React Node Angular SAS Storm Elastic Search Xamarin Microservices Consul Kafka PDW Splunk Redis SQL Puppet Jenkins Apache Hive Apache Tez
  • 11. What is chaos engineering?
  • 12. It’s just wreaking havoc with your code for fun, right?
  • 13.
  • 14. Chaos Engineering is… Controlled experiments on a distributed system that help you build confidence in the system’s ability to tolerate the inevitable failures.
  • 15.
  • 16. Principles of Chaos Engineering 1. Define “normal” 2. Assume ”normal” will continue in both a control group and an experimental group. 3. Introduce chaos: servers that crash, hard drives that malfunction, network connections that are severed, etc. 4. Look for a difference in behavior between the control group and the experimental group.
  • 17. Going farther Build a Hypothesis around Normal Behavior Vary Real-world Events Run Experiments in Production Automate Experiments to Run Continuously From http://principlesofchaos.org/
  • 18. Benefits of chaos engineering
  • 19. Benefits of chaos engineering You're awake Design for failure Healthy systems Self service
  • 20. Current examples of chaos engineering
  • 21. Maybe you meant Netflix’s Chaos Monkey?
  • 22. How is Jet different?
  • 23. We’re not testing in prod (yet).
  • 24. SQL restarts & geo-replication Start - Checks the source db for write access - Renames db on destination server (to create a new one) - Creates a geo-replication in the destination region Stop - Shuts down cloud services writing to source db - Sets source db as read-only - Ends continuous copy - Allows writes to secondary db
  • 27.
  • 28. I have now delivered three business critical projects written in F#. I am still waiting for the first bug to come in. Simon Cousins UK Power company “ “ “
  • 29. Concise and 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 C# F# Trivial to pattern match on!
  • 31. Concise and 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#
  • 33. Expanded feature set: Type providers 920 pages! 31 lines!
  • 34. TickSpec – an F# project Thanks to Scott Wlaschin for his post, Cycles and modularity in the wild
  • 35. SpecFlow– a comparable C# project Thanks to Scott Wlaschin for his post, Cycles and modularity in the wild
  • 36. Entity Framework (C#) Thanks to Scott Wlaschin for his post, Cycles and modularity in the wild
  • 38. Our code! let selectRandomInstance compute hostedService = async { try let! details = getHostedServiceDetails compute hostedService.ServiceName let deployment = getProductionDeployment details let instance = deployment.RoleInstances |> Seq.toArray |> randomPick return details.ServiceName, deployment.Name, instance with e -> log.error "Failed selecting random instancen%A" e reraise e }
  • 39. Our code! let restartRandomInstance compute hostedService = async { try let! serviceName, deploymentId, roleInstance = selectRandomInstance compute hostedService match roleInstance.PowerState with | RoleInstancePowerState.Stopped -> log.info "Service=%s Instance=%s is stopped...ignoring...” serviceName roleInstance.InstanceName | _ -> do! restartInstance compute serviceName deploymentId roleInstance.InstanceName with e -> log.error "%s" e.Message }
  • 40. Our code! compute |> getHostedServices |> Seq.filter ignoreList |> knuthShuffle |> Seq.distinctBy (fun a -> a.ServiceName) |> Seq.map (fun hostedService -> async { try return! restartRandomInstance compute hostedService with e -> log.warn "failed: service=%s . %A" hostedService.ServiceName e return () }) |> Async.ParallelIgnore 1 |> Async.RunSynchronously
  • 43. Additional chaos finds - Redis - Checkpointing
  • 44.
  • 45. If availability matters, you should be testing for it.
  • 46. Azure + F# + Chaos = <3
  • 47. Chaos Engineering at Jet.com Rachel Reese | @rachelreese | rachelree.se Jet Technology | @JetTechnology | tech.jet.com

Hinweis der Redaktion

  1. Should test and make sure that what we’re building can actually handle that. Systems should have more variance! Part of how they detected the Volkswagen test fiasco: no variability in tests! Not enough chaos!
  2. You might not think we need chaos because we do alllll these other kinds of testing.
  3. But have you tested for timeouts? Have you tested your failover setups? All the automated and manual testing can’t necessarily find issues like css failing because of a timeout. Not a good experience!
  4. Just because you've tested your components, doesn't mean the interactions between them are solid 3-5 mins
  5. Let's back up.
  6. 400-1000 microservices.
  7. Right tool for the job company. Chaos testing is the right tool. Azure: Storage Q for At-least-once Svc bus for At-most-once, transactions, persistence, order guarantee and Kafka for event distribution 5-7 mins
  8. More even distribution of complexity: easier to create & maintain services (very small amount of logic), harder to manage all services. Shift complexity from biz logic to infrastructure. Better than one giant monolithic solution with 25 projects!
  9. Break all the things! Why is breaking things good? Just causes inconvenience. Ugh! (upgrading things is bad because breaks things!)
  10. What could possibly go wrong?
  11. paraphrased from http://principlesofchaos.org/
  12. Controlled burn to stave off proper forest fire.
  13. Paraphrased from http://principlesofchaos.org/
  14. 1: The overall system’s throughput, error rates, latency percentiles, etc. could all be metrics of interest representing steady state behavior. 2: Consider events that correspond to hardware failures like servers dying, software failures like malformed responses, and non-failure events like a spike in traffic or a scaling event. 3: Prod, to guarantee both authenticity of the way in which the system is exercised and relevance to the current deployed system. 4: Running experiments manually is labor-intensive and ultimately unsustainable. 10-15 mins
  15. Outages happen when engineers are available, awake and able to resolve. Engineers start designing for failure. Prevents later outages & makes systems immune to failure. Self service. Devs will WANT to test failure. (can I break chaos testing?? And have everything work??) If availability matters, you should be testing for it. This is a best practices move. 12-17 mins
  16. Chaos engineering - Chaos Gorilla is similar to Chaos Monkey, but simulates an outage of an entire Amazon availability zone.  Janitor Monkey searches for unused resources and disposes of them. Conformity Monkey finds instances that don’t adhere to best-practices and shuts them down.  There’s also WazMonkey for Azure: Can’t stop instances, only an entire cluster Use in-house architecture + F#  Chaos should be part of the continuous integration cycle
  17. Startup. First goal, launch. Second, get everything right. (much socialization.) Takes a lot to convince devs that it’s not just okay, but valuable to break things at all. Much less in prod. Netflix: can't test in QA because not "real system". Too expensive to create exact backup.
  18. We have all service restarts logged in splunk, plus tests in jenkins. (Cross-reference). [to check if chaos caused failures] Architecture diagram for all of this -> show parts that are breaking. Setting as read-only ensures no corrupt data. Having created chaos made this much easier to automate.
  19. 15-20 mins
  20. Before we show code, let’s cover why we chose F#
  21. The Jet story on why we chose F#. F# for pricing engine because: - less code leading to fewer bugs - robust and safer code because of the type system. Validation, logging, other cross-cutting concerns. Using attributes to inject an extra function call before your functions is common in Web API, and other frameworks We needed to handle cross-cutting concerns for services NOT based on HTTP. Very difficult to do in a generic way. 
  22. The Jet story on why we chose F#. F# for pricing engine because: - less code leading to fewer bugs - robust and safer code because of the type system. Validation, logging, other cross-cutting concerns. Using attributes to inject an extra function call before your functions is common in Web API, and other frameworks We needed to handle cross-cutting concerns for services NOT based on HTTP. Very difficult to do in a generic way. 
  23. Once inputs and outputs are defined, code is just a series of transformations. Can compose or pipe the operations. Will help Composing handlers and avoiding handler’s hell. Subscription and handlers should be defined as a series of functions, outside the Micro Service. Functional! Using Async.Seq OO Patterns: command pattern, visitor pattern are both just higher order functions. HO fns often can more easily express a complex work flow. Now, why F# specifically?
  24. Fewer bugs come from less code.
  25. Fewer bugs come from less code. Rewrote into prod in 6 weeks!!
  26. Option type is a simple discriminated union. Both are idiomatic. C# version still lacks structural equality. Would need to override equality, comparison, AND GetHashCode. Also not proper immutability because private set is still mutable. -- there should be no setter, and the backing field should be readonly. Pattern matching is like a switch statement, but WAY more powerful.
  27. Option type is a simple discriminated union. Both are idiomatic. C# version still lacks structural equality (based on contents): that means overriding the equality implementation, the comparison implementation, AND GetHashCode. (generates a hash code from your object instance). Also not proper immutability because private set is still mutable. To get real immutability, there should be no setter, and the backing field should be readonly. Pattern matching is like a switch statement, but WAY more powerful.
  28. Thor. unit vs case vs pallet.
  29. E.g.: TickSpec: StepDefinitions depends on TickSpec: Feature
  30. Decreased complexity = more time to get details correct. 30-35 mins
  31. ORM
  32. Why microservices? F#: data in -> data out; inputs -> outputs. A function. A microservice = just a function that naturally maps to an f# script, with input/out via the network. Also, naming: Best practices = naming services after the function they perform. Bad: “sku service” , good: “import skus" No explicit meeting where we decided to do microservices, one day we just realized we had a bunch of microservices
  33. Decode >> Handle >> interpret Allows one fun to be called to implement. Being functional allows composition here.
  34. Within the chaos microservice handle: compute is type ComputeManagementClient: provides the ability for me to work with most of the Azure compute landscape – hosted services, locations, virtual machines, and so on. I’ve removed additional logging (checking for only one service role instance, eg.)
  35. These bits of code, btw are all part of one microservice for chaos.
  36. Just cloud services. Not VMs. Add bits on torch maybe. Async.ParallelIgnore: -- it doesn’t keep track of the results of the asyncs it executes, this way it can schedule an unbounded sequence of them. -- second it allows us to place a bound on parallelism at a given point in time - this is useful because too much parallelism can create too much contention and reduce throughput, increase latency. -- finally, it starts each computation on the calling thread [this is faster in many scenarios, but if still desired to queue the work item, it is still possible via Async.SwitchToThreadPool.] 35-40 mins
  37. - Manual testers noticed search not resulting in data. Then Pricing team saw timeouts. Then realized: Search team wasn’t handling those timeouts properly, began throwing “Operation Canceled” exceptions. (Should have been caught at a high-level) Then found out: Elasticsearch was completely down and had cascaded issues downstream (from search to pricing back to search, etc.). We mapped the Elasticsearch downtime to a restart of Elastic Search in Chaos testing & found out it was a single instance (so we brought down the entire service.) It took days for DevOps to bring this instance back up and it was then moved to a proper cluster in QA.
  38. Chaos restarted Redis: We hadn’t enabled DNS for our redis cluster (necessary to support automatic failover!) We updated checkpointing to a new system, but never updated our failover scripts.
  39. tie back. if this/css etc. fails here, we find that, can fix it. So basically, in conclusion: 40-45 mins
  40. In conclusion: Chaos should be part of your best practices. Can help find/fix errors in your systems before your customers have them.