Slide 1

Slide 1 text

Using Feature Flags How to Split a Monolith Joy Ebertz Sr Staff Engineer

Slide 2

Slide 2 text

Who am I? https://medium.com/@jkebertz

Slide 3

Slide 3 text

Who am I? • At Box • Worked on many aspects of splitting a monolith • Architecture • Authorization service • Service moving functionality • At Split • Work on a feature flagging system • Starting to think through splitting our monolith

Slide 4

Slide 4 text

Agenda • What are feature flags? • Why split a monolith? • Challenges of Splitting a Monolith • How can feature flags help?

Slide 5

Slide 5 text

What Are Feature Flags?

Slide 6

Slide 6 text

Other Terms • Feature Toggle • Feature Flip • Feature Switch • Conditional Feature • Split

Slide 7

Slide 7 text

Code Branch Controlled by GUI

Slide 8

Slide 8 text

Code Sample if (Treatments.ON .equals(_splitClient.getTreatment(orgId, Splits.MY_FEATURE.name()))) { // Do Something } else { // Do Something Else }

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Code Sample if (Treatments.ON.equals(_splitClient.getTreatment(orgId, Splits.MY_FEATURE.splitName()))) { // Do Something } else { // Do Something Else }

Slide 11

Slide 11 text

Main Use-Cases • Releasing features • Production Testing • A/B/C Testing • Custom Packages • Temporary UI Customization

Slide 12

Slide 12 text

Main Use-Cases • Releasing features • Production Testing • A/B/C Testing • Custom Packages • Temporary UI Customization

Slide 13

Slide 13 text

Releasing Features • Separating Deploy from Release • Canary/Ramped Deployment • Off Switch

Slide 14

Slide 14 text

Deploy Release

Slide 15

Slide 15 text

Slide 16

Slide 16 text

User

Slide 17

Slide 17 text

Prod User

Slide 18

Slide 18 text

Prod User

Slide 19

Slide 19 text

Prod Developer

Slide 20

Slide 20 text

Prod Developer

Slide 21

Slide 21 text

Prod User

Slide 22

Slide 22 text

Prod User Split

Slide 23

Slide 23 text

Prod User Split OFF OFF

Slide 24

Slide 24 text

Prod User Split OFF

Slide 25

Slide 25 text

Prod User Split OFF

Slide 26

Slide 26 text

Prod Split Product Owner OFF

Slide 27

Slide 27 text

Prod Split Product Owner ON

Slide 28

Slide 28 text

Prod User Split ON

Slide 29

Slide 29 text

Prod User Split ON

Slide 30

Slide 30 text

Prod User Split ON

Slide 31

Slide 31 text

Prod User Split ON

Slide 32

Slide 32 text

Prod Developer

Slide 33

Slide 33 text

Prod Developer

Slide 34

Slide 34 text

Prod User Split 10%

Slide 35

Slide 35 text

Prod User Split 20%

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Why Should We Split a Monolith?

Slide 39

Slide 39 text

What do I mean by “Splitting a Monolith?”

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Why Split a Monolith? Code Entanglement

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

Controllers Models Smarty Templates

Slide 53

Slide 53 text

Controllers Models Smarty Templates Actions!

Slide 54

Slide 54 text

Controllers Models Smarty Templates Actions

Slide 55

Slide 55 text

Controllers Models Smarty Templates Actions New Actions

Slide 56

Slide 56 text

New Actions Controllers Models Smarty Templates Actions New Actions

Slide 57

Slide 57 text

Controllers Models Smarty/Brainy Templates Actions New Actions New New Actions Commands Views Services Resolvers Runmode

Slide 58

Slide 58 text

Controllers Models Smarty Templates Actions New Actions New New Actions Command s Views Services Resolvers Runmode

Slide 59

Slide 59 text

Controllers Models Smarty Templates Actions New Actions New New Actions Command s Views Services Resolvers Runmode

Slide 60

Slide 60 text

Controllers Models Smarty Templates Actions New Actions New New Actions Command s Views Services Resolvers Runmode

Slide 61

Slide 61 text

Controllers Models Smarty/Brainy Templates Actions New Actions New New Actions Commands Views Services Resolvers Runmode

Slide 62

Slide 62 text

Controllers Models Actions New Actions New New Actions Commands Views Services Resolvers Runmode Smarty/Brainy Templates Webapp Controller Webapp DataProvider

Slide 63

Slide 63 text

Controllers Models Actions New Actions New New Actions Commands Views Services Resolvers Runmode Smarty/Brainy Templates Webapp Controller Webapp DataProvider

Slide 64

Slide 64 text

Unclear Ownership

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

Deployment Problems

Slide 70

Slide 70 text

Build Test Deploy

Slide 71

Slide 71 text

Build Test Deploy

Slide 72

Slide 72 text

Build Test Deploy

Slide 73

Slide 73 text

Build Test Deploy

Slide 74

Slide 74 text

Build Test Deploy

Slide 75

Slide 75 text

Build Test Deploy

Slide 76

Slide 76 text

Build Test Deploy

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

10% 10% 10% Deploy 72% Chance Of Success

Slide 82

Slide 82 text

10% 10% 10% Deploy 53% Chance Of Success 10% 10% 10%

Slide 83

Slide 83 text

10% 10% 10% Deploy 28% Chance Of Success 10% 10% 10% 10% 10% 10% 10% 10% 10%

Slide 84

Slide 84 text

Deploy 1% Chance Of Success

Slide 85

Slide 85 text

Deploy

Slide 86

Slide 86 text

Deploy

Slide 87

Slide 87 text

Deploy

Slide 88

Slide 88 text

Deploy

Slide 89

Slide 89 text

Challenges of Splitting a Monolith

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

Original Code Tangled

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

Entirely Separate Talk

Slide 94

Slide 94 text

Trying to Replicate Functionality

Slide 95

Slide 95 text

Entirely New Infrastructure

Slide 96

Slide 96 text

Entirely New Infrastructure

Slide 97

Slide 97 text

RISKY

Slide 98

Slide 98 text

So, how can we mitigate the risks?

Slide 99

Slide 99 text

Using Feature Flags to Split a Monolith

Slide 100

Slide 100 text

Minimize Move

Slide 101

Slide 101 text

Remove Dead Code

Slide 102

Slide 102 text

Why is your code dead? Method no longer referenced Parameter never has certain values Endpoint never called

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

log.info(“CODE NOT DEAD UID: 12345”);

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

private void logForCleanup(String orgId, String uid) { if (Treatments.ON .equals(_splitClient.getTreatment(orgId, Splits.CLEANUP.name()))) { String message = String.format(“CODE NOT DEAD UID: %s”, uid); log.info(message); } }

Slide 107

Slide 107 text

private void logForCleanup(String orgId, String uid) { if (Treatments.ON .equals(_splitClient.getTreatment(orgId, Splits.CLEANUP.name()))) { String message = String.format(“CODE NOT DEAD UID: %s”, uid); log.info(message); } } Turn on CLEANUP split to 1%

Slide 108

Slide 108 text

1. Roll out to 1% 2. Remove any lines hit 3. Roll out to 5% 4. Remove any lines hit 5. Roll out to 100% (leave here as long as makes you comfortable) 6. Remove any code that hasn’t been hit

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

Requests Monolith logic

Slide 111

Slide 111 text

Requests Monolith logic Interface

Slide 112

Slide 112 text

Requests Monolith logic New Microservice Interface Interface

Slide 113

Slide 113 text

Requests Monolith logic New Microservice Interface Interface

Slide 114

Slide 114 text

Requests Monolith logic New Microservice Interface Interface

Slide 115

Slide 115 text

Stress Test Your New Systems

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

Requests Monolith logic New Microservice Mirrored Traffic

Slide 118

Slide 118 text

Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic

Slide 119

Slide 119 text

Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic

Slide 120

Slide 120 text

Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic

Slide 121

Slide 121 text

Requests New Microservice Mirrored Traffic Feature Flag Check Monolith logic

Slide 122

Slide 122 text

Verify Parity

Slide 123

Slide 123 text

Requests New Microservice Feature Flag Parity Check Monolith logic

Slide 124

Slide 124 text

Requests New Microservice Feature Flag Parity Check Monolith logic

Slide 125

Slide 125 text

Requests New Microservice Feature Flag Parity Check Monolith logic

Slide 126

Slide 126 text

Requests New Microservice Feature Flag Parity Check Monolith logic

Slide 127

Slide 127 text

Requests New Microservice Feature Flag Parity Check Monolith logic Log if different

Slide 128

Slide 128 text

Requests New Microservice Feature Flag Parity Check Monolith logic Log if different

Slide 129

Slide 129 text

Requests New Microservice Feature Flag Parity Check Monolith logic Log if different

Slide 130

Slide 130 text

Slowly Roll Over Traffic

Slide 131

Slide 131 text

Slowly Roll Over Traffic 1%

Slide 132

Slide 132 text

Slowly Roll Over Traffic Free Users

Slide 133

Slide 133 text

Slowly Roll Over Traffic Internal Users

Slide 134

Slide 134 text

Slowly Roll Over Traffic Test Traffic Only

Slide 135

Slide 135 text

Slowly Roll Over Traffic

Slide 136

Slide 136 text

• Treatments.OLD • Treatments.NEW • Treatments.BOTH • Treatments.PARITY Default OFF treatment

Slide 137

Slide 137 text

Requests New Microservice Monolith logic Treatments.OLD

Slide 138

Slide 138 text

Requests New Microservice Monolith logic Treatments.NEW

Slide 139

Slide 139 text

Requests New Microservice Mirrored Traffic Monolith logic Treatments.BOTH

Slide 140

Slide 140 text

Requests New Microservice Monolith logic Treatments.PARITY Parity Check

Slide 141

Slide 141 text

Summary • What are feature flags? • Why split a monolith? • Challenges of Splitting a Monolith • How can feature flags help? • Remove dead code • Load test • Parity check • Gradual roll out/kill switch

Slide 142

Slide 142 text

What Are Feature Flags? Joy Ebertz @jkebertz Thank You!