SlideShare a Scribd company logo
1 of 31
Download to read offline
SUCCESS STORY: HOW TO SWITCH STACK WITHOUT DOWNTIME
THE LEADER OF URBAN & ON-DEMAND LOGISTICS
Our mission is to connect merchants,
customers and local couriers to speed-up
the way goods are transported in cities
04
MERCHANTS TRUST US
GROWING LIST OF TOP-TIER REFERENCES ACROSS VERTICALS
05
TEAM
GROWING AND TALENTED ORGANISATION
CLÉMENT BENOIT
Co-Founder & CEO
Resto-in founder
BENJAMIN CHEMLA
Co-Founder & VP
Sales
Citycake founder
DAMIEN BON
COO
BCG
INSEAD
Lehman Brothers
FABIEN PENSO
CTO
Process-One
CloudScreener
Causes
We manage a team of 80 people coming from the best companies
06
ABOUT ME
1995: Started using Linux
1998: LinuxFr - a French Linux community website
1999: DBee - First company
Since 2010: Causes, BBC, Cloudscreener, Stuart
PAST EXPERIENCES
@fabienpenso
http://penso.info
Short Video
08
INFRASTRUCTURE 2015
09
SOFTWARE STACK 2015
Standard LAMP + RabbitMQ + Crontab
0% test
coverage
GPA: 3.40 90k LOC 150 SQL
tables
10
API REQUESTS PROCESSED IN 2015
SLOW PHP REQUEST
PROCESSING
(INCLUDES PSEUDO
BACKGROUND
TASKS)
REACH MAX
AMOUNT OF PHP
PROCESSES
QUICKLY
MINIMUM INTERVAL
FOR TASKS IS 1
MINUTE
INEFFICIENT
STORAGE FOR
BACKGROUND
TASKS
11
LOOKING FOR A NEW STACK OPTION
12
HOW TO SWITCH: TWO PATHWAYS
Option A
Write all from the ground up,
new Rails project, then write a
script to move all existing data.
+ Clean code, no legacy
once moved.
- Can't rollback, long time
before seeing
improvements
- High chance of failure
Option B
Write small pieces of code to
work with the existing context/
environment.
+ Business doesn't stop,
can still add features, and
fix existing bugs
- Manage 2 platforms for
months, new code
connects to old storage
schema, must replicate
bad code structure
13
QUICK CODE GENERATION
Automatic code generation - ActiveRecord Ruby
code from SQL tables
Backoffice - Install ActiveAdmin to view all AR
classes and records
Continuous Integration - Setup deployment
Gem - php_serialize, annotate, devise
# == Schema Information
#
# Table name: vehicle
#
# id :integer not null, primary key
# driver_id :integer
# brand :string(100)
# model :string(150)
# number_plate :string(20)
# color :string(45)
# insurance :string(255)
# vehicle_registration :string(255)
class Vehicle < ActiveRecord::Base
end
14
RUNNING BOTH PLATFORM
Refactor Feature Flag Ruby Feedback
Encapsulate the
PHP feature within
a single function
call
Add a feature flag in
the PHP code to enable/
disable this call
QA team enable
the feature on
staging, and verify
it works as
expected
Implement the
next "feature"
Clone code in
Ruby, add an
opposite feature
flag
15
IMPLEMENTING NEW CODE
Production
16
HAVE A PLAN
Split the legacy
codebase into
virtual modules
Rewrite an easy
one at first
Rewrite them in
order of
importance
Finish with low
priority non critical
code
17
IMPROVE LEGACY CODE
Add AR model validation
class Job < ActiveRecord::Base
validates :expires_at, presence: true
validate :payment_ability, on: :create
def payment_ability
if !has_funds? && !credit_card
errors.add(:credit_card, "meaningful message")
end
end
end
Ruby
Run validation for every SQL
changes
Warn about invalid models on Slack
<?php
// … code
class EntityListener {
protected $sidekiqJobPusher;
public function __construct(TransactionQueueService $redisClient) {
$this->sidekiqJobPusher = $redisClient;
}
public function onUpdate($calledEntity, UnitOfWork $uow) {
$this->sidekiqJobPusher->performActiveJob("PhpJob",
[$calledEntityName, $id, 'php_after_updated', $changedValues], true, "php");
}
public function onInsert($calledEntity) {
$this->sidekiqJobPusher->performActiveJob("PhpJob",
[$calledEntityName, $id, 'php_after_created'], true, "php");
}
}
?>
PHP Method injections
18
IMPROVE LEGACY CODE
# app/models/concerns/php_callbacks.rb
module PhpCallbacks
def php_after_created(_options = {})
return if valid?
message = "#{self.class}: #{id} errors: #{errors.full_messages.to_sentence}"
Service::Slack.ping message, channel: "#exceptions-#{Rails.env}"
end
alias php_after_updated php_after_created
End
# app/jobs/php_job.rb
class PhpJob < ActiveJob::Base
queue_as :php
include JobLogger
ACCEPTED_METHODS = %w(php_after_updated php_after_created).freeze
def perform(klass_type, id, method, *args)
unless ACCEPTED_METHODS.include?(method)
raise ArgumentError.new("`method` can only be #{ACCEPTED_METHODS.join(' or ')}!")
end
klass = klass_type.constantize rescue nil
if klass && klass.method_defined?(method.to_sym)
object = klass.find(id)
object.send(method, *args)
end
end
end
Ruby validation execution
19
IMPROVE LEGACY CODE
20
FEATURE FLAG
FEATURE FLAG: ABILITY TO TURN FEATURE ON/OFF
PHP
use OpensoftRolloutRollout;

use OpensoftRolloutStorageArrayStorage;


$rollout = new Rollout(new ArrayStorage());
$rollout->isActive('outgoing_email');
Ruby
require "redis"

require "rollout"

$redis = Redis.new

$rollout = Rollout.new($redis)
$rollout.active?(:outgoing_email)
https://github.com/opensoft/rollout (PHP)
https://github.com/fetlife/rollout (Ruby)
21
REMOVE OVERENGINEERED CODE
TOO MANY SQL TABLES
Before: 150 tables
After: 90 tables
class DriverStatusType
include TypableModel
read_only_attr :id, :code, :name
defaults [
[1, "off_duty", "Off Duty"],
[2, "on_duty", "On Duty"],
[3, "busy", "Busy"],
[4, "pending", "Pending"],
[5, "rejected", "Rejected"]
]
end
DriverStatusType.find_by(id: 1)
DriverStatusType.find_by(code: :on_duty)
22
MOVE API ENDPOINTS
List ALL API
endpoints currently
used looking at the
PHP logs
68 endpoints to move
Make a plan
23
MOVE API ENDPOINTS
Move one non critical
API endpoint
Move by importance,
most critical first
Good potential: https://getkong.org
Be able to turn each
api endpoint on/off
Grape Routing Feedback
Implement the API
endpoint in Ruby
Move this API
endpoint to Ruby in the
nginx routing file on
staging
Implement the
next api endpoint
QA team verify it
works as
expected
24
MOVE API ENDPOINTS
Production
25
MOVE API ENDPOINTS
TOOLS: LIST OUR QA USED FOR TESTING
Runscope.com
Selenium
Android Espresso
iOS xcode test
Postman and curl
Charles HTTP Proxy
26
INFRASTRUCTURE 2016
27
CLOSING: SOFTWARE STACK 2015
Standard LAMP + RabbitMQ + Crontab
0% test
coverage
GPA: 3.40 90k LOC 150 SQL
tables
28
CLOSING: SOFTWARE STACK 2016
Grape + Sidekiq + Rails
70% test
coverage
GPA: 3.95 15k LOC 90 SQL
tables
How long to move all the
code
?
30
CLOSING
ROOM FOR IMPROVEMENT: WHAT WOULD WE DO DIFFERENT?
Ability to have ephemeral servers Give more power to the QA
Engineers
@fabienpenso

More Related Content

Similar to HOW TO SWITCH STACK WITHOUT DOWNTIME

IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesChris Bailey
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaAmazon Web Services
 
The road to continuous deployment (DomCode September 2016)
The road to continuous deployment (DomCode September 2016)The road to continuous deployment (DomCode September 2016)
The road to continuous deployment (DomCode September 2016)Michiel Rook
 
Developer intro to open shift
Developer intro to open shiftDeveloper intro to open shift
Developer intro to open shiftRam Maddali
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaPantheon
 
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 MoreC4Media
 
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Henning Jacobs
 
Building a Serverless company with Node.js, React and the Serverless Framewor...
Building a Serverless company with Node.js, React and the Serverless Framewor...Building a Serverless company with Node.js, React and the Serverless Framewor...
Building a Serverless company with Node.js, React and the Serverless Framewor...Luciano Mammino
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleRaimonds Simanovskis
 
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Yan Cui
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0Eugenio Romano
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containersinside-BigData.com
 
Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Yan Cui
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesChris Bailey
 
Federico Feroldi - Scala microservices
Federico Feroldi - Scala microservicesFederico Feroldi - Scala microservices
Federico Feroldi - Scala microservicesScala Italy
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenchesYan Cui
 
Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Yan Cui
 
From Code to Cloud - PHP on Red Hat's OpenShift
From Code to Cloud - PHP on Red Hat's OpenShiftFrom Code to Cloud - PHP on Red Hat's OpenShift
From Code to Cloud - PHP on Red Hat's OpenShiftEric D. Schabell
 

Similar to HOW TO SWITCH STACK WITHOUT DOWNTIME (20)

IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 
The road to continuous deployment (DomCode September 2016)
The road to continuous deployment (DomCode September 2016)The road to continuous deployment (DomCode September 2016)
The road to continuous deployment (DomCode September 2016)
 
Developer intro to open shift
Developer intro to open shiftDeveloper intro to open shift
Developer intro to open shift
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon Vienna
 
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
 
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
 
Building a Serverless company with Node.js, React and the Serverless Framewor...
Building a Serverless company with Node.js, React and the Serverless Framewor...Building a Serverless company with Node.js, React and the Serverless Framewor...
Building a Serverless company with Node.js, React and the Serverless Framewor...
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
 
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containers
 
Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
 
Federico Feroldi - Scala microservices
Federico Feroldi - Scala microservicesFederico Feroldi - Scala microservices
Federico Feroldi - Scala microservices
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenches
 
Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)
 
From Code to Cloud - PHP on Red Hat's OpenShift
From Code to Cloud - PHP on Red Hat's OpenShiftFrom Code to Cloud - PHP on Red Hat's OpenShift
From Code to Cloud - PHP on Red Hat's OpenShift
 

Recently uploaded

Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 

Recently uploaded (20)

Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 

HOW TO SWITCH STACK WITHOUT DOWNTIME

  • 1. SUCCESS STORY: HOW TO SWITCH STACK WITHOUT DOWNTIME
  • 2. THE LEADER OF URBAN & ON-DEMAND LOGISTICS
  • 3. Our mission is to connect merchants, customers and local couriers to speed-up the way goods are transported in cities
  • 4. 04 MERCHANTS TRUST US GROWING LIST OF TOP-TIER REFERENCES ACROSS VERTICALS
  • 5. 05 TEAM GROWING AND TALENTED ORGANISATION CLÉMENT BENOIT Co-Founder & CEO Resto-in founder BENJAMIN CHEMLA Co-Founder & VP Sales Citycake founder DAMIEN BON COO BCG INSEAD Lehman Brothers FABIEN PENSO CTO Process-One CloudScreener Causes We manage a team of 80 people coming from the best companies
  • 6. 06 ABOUT ME 1995: Started using Linux 1998: LinuxFr - a French Linux community website 1999: DBee - First company Since 2010: Causes, BBC, Cloudscreener, Stuart PAST EXPERIENCES @fabienpenso http://penso.info
  • 9. 09 SOFTWARE STACK 2015 Standard LAMP + RabbitMQ + Crontab 0% test coverage GPA: 3.40 90k LOC 150 SQL tables
  • 10. 10 API REQUESTS PROCESSED IN 2015 SLOW PHP REQUEST PROCESSING (INCLUDES PSEUDO BACKGROUND TASKS) REACH MAX AMOUNT OF PHP PROCESSES QUICKLY MINIMUM INTERVAL FOR TASKS IS 1 MINUTE INEFFICIENT STORAGE FOR BACKGROUND TASKS
  • 11. 11 LOOKING FOR A NEW STACK OPTION
  • 12. 12 HOW TO SWITCH: TWO PATHWAYS Option A Write all from the ground up, new Rails project, then write a script to move all existing data. + Clean code, no legacy once moved. - Can't rollback, long time before seeing improvements - High chance of failure Option B Write small pieces of code to work with the existing context/ environment. + Business doesn't stop, can still add features, and fix existing bugs - Manage 2 platforms for months, new code connects to old storage schema, must replicate bad code structure
  • 13. 13 QUICK CODE GENERATION Automatic code generation - ActiveRecord Ruby code from SQL tables Backoffice - Install ActiveAdmin to view all AR classes and records Continuous Integration - Setup deployment Gem - php_serialize, annotate, devise # == Schema Information # # Table name: vehicle # # id :integer not null, primary key # driver_id :integer # brand :string(100) # model :string(150) # number_plate :string(20) # color :string(45) # insurance :string(255) # vehicle_registration :string(255) class Vehicle < ActiveRecord::Base end
  • 15. Refactor Feature Flag Ruby Feedback Encapsulate the PHP feature within a single function call Add a feature flag in the PHP code to enable/ disable this call QA team enable the feature on staging, and verify it works as expected Implement the next "feature" Clone code in Ruby, add an opposite feature flag 15 IMPLEMENTING NEW CODE Production
  • 16. 16 HAVE A PLAN Split the legacy codebase into virtual modules Rewrite an easy one at first Rewrite them in order of importance Finish with low priority non critical code
  • 17. 17 IMPROVE LEGACY CODE Add AR model validation class Job < ActiveRecord::Base validates :expires_at, presence: true validate :payment_ability, on: :create def payment_ability if !has_funds? && !credit_card errors.add(:credit_card, "meaningful message") end end end Ruby Run validation for every SQL changes Warn about invalid models on Slack
  • 18. <?php // … code class EntityListener { protected $sidekiqJobPusher; public function __construct(TransactionQueueService $redisClient) { $this->sidekiqJobPusher = $redisClient; } public function onUpdate($calledEntity, UnitOfWork $uow) { $this->sidekiqJobPusher->performActiveJob("PhpJob", [$calledEntityName, $id, 'php_after_updated', $changedValues], true, "php"); } public function onInsert($calledEntity) { $this->sidekiqJobPusher->performActiveJob("PhpJob", [$calledEntityName, $id, 'php_after_created'], true, "php"); } } ?> PHP Method injections 18 IMPROVE LEGACY CODE
  • 19. # app/models/concerns/php_callbacks.rb module PhpCallbacks def php_after_created(_options = {}) return if valid? message = "#{self.class}: #{id} errors: #{errors.full_messages.to_sentence}" Service::Slack.ping message, channel: "#exceptions-#{Rails.env}" end alias php_after_updated php_after_created End # app/jobs/php_job.rb class PhpJob < ActiveJob::Base queue_as :php include JobLogger ACCEPTED_METHODS = %w(php_after_updated php_after_created).freeze def perform(klass_type, id, method, *args) unless ACCEPTED_METHODS.include?(method) raise ArgumentError.new("`method` can only be #{ACCEPTED_METHODS.join(' or ')}!") end klass = klass_type.constantize rescue nil if klass && klass.method_defined?(method.to_sym) object = klass.find(id) object.send(method, *args) end end end Ruby validation execution 19 IMPROVE LEGACY CODE
  • 20. 20 FEATURE FLAG FEATURE FLAG: ABILITY TO TURN FEATURE ON/OFF PHP use OpensoftRolloutRollout;
 use OpensoftRolloutStorageArrayStorage; 
 $rollout = new Rollout(new ArrayStorage()); $rollout->isActive('outgoing_email'); Ruby require "redis"
 require "rollout"
 $redis = Redis.new
 $rollout = Rollout.new($redis) $rollout.active?(:outgoing_email) https://github.com/opensoft/rollout (PHP) https://github.com/fetlife/rollout (Ruby)
  • 21. 21 REMOVE OVERENGINEERED CODE TOO MANY SQL TABLES Before: 150 tables After: 90 tables class DriverStatusType include TypableModel read_only_attr :id, :code, :name defaults [ [1, "off_duty", "Off Duty"], [2, "on_duty", "On Duty"], [3, "busy", "Busy"], [4, "pending", "Pending"], [5, "rejected", "Rejected"] ] end DriverStatusType.find_by(id: 1) DriverStatusType.find_by(code: :on_duty)
  • 22. 22 MOVE API ENDPOINTS List ALL API endpoints currently used looking at the PHP logs 68 endpoints to move Make a plan
  • 23. 23 MOVE API ENDPOINTS Move one non critical API endpoint Move by importance, most critical first Good potential: https://getkong.org Be able to turn each api endpoint on/off
  • 24. Grape Routing Feedback Implement the API endpoint in Ruby Move this API endpoint to Ruby in the nginx routing file on staging Implement the next api endpoint QA team verify it works as expected 24 MOVE API ENDPOINTS Production
  • 25. 25 MOVE API ENDPOINTS TOOLS: LIST OUR QA USED FOR TESTING Runscope.com Selenium Android Espresso iOS xcode test Postman and curl Charles HTTP Proxy
  • 27. 27 CLOSING: SOFTWARE STACK 2015 Standard LAMP + RabbitMQ + Crontab 0% test coverage GPA: 3.40 90k LOC 150 SQL tables
  • 28. 28 CLOSING: SOFTWARE STACK 2016 Grape + Sidekiq + Rails 70% test coverage GPA: 3.95 15k LOC 90 SQL tables
  • 29. How long to move all the code ?
  • 30. 30 CLOSING ROOM FOR IMPROVEMENT: WHAT WOULD WE DO DIFFERENT? Ability to have ephemeral servers Give more power to the QA Engineers