RubyConf Taiwan 2016 - Large scale Rails applications

Florian Dutey
Florian DuteySenior Backend developer at Strikingly
Large scale Rails
applications
Florian Dutey
www.strikingly.com
We hire!
2007
1.2.3
Fat Models
Skinny Controllers
If it’s not a controller job,
leave it to the model.
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
If the screwdriver can’t solve it,
use the hammer.
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
Business complexity
Technical complexity
Solution = Complexity²
Rails doesn't scale!
NOT Rails!
Application
Http
Request
Response
Request Router Controller
ResponseView
Models
Request Router Controller
ResponseView
Models
Application
Principles
• Modularity
• Single Responsibility Object
• Plain Old Ruby Objects
• Inversion Of Control
• Stateless Objects
• Domain Specific Language
Modularity
• Controller
• Test
• Rake tasks
• Jobs
• Daemons
• …
Single Responsibility Principle
(SRP)
Not SRP
SRP
User
email
password
first_name
last_name
address_1
address_2
zip_code
city
country
User
email
password
User::Profile
user_id
first_name
last_name
User::Address
user_id
address_1
address_2
zip_code
city
country
Break things down
minimalist objects
“Make everything as simple as possible,
but not simpler.”
Albert Einstein
Plain Old Ruby Objects (PORO)
PORO
RubyConf Taiwan 2016 - Large scale Rails applications
Not PORO
Inversion of controls
Separate what
and when
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
Why?
• Separate responsibilities
• Remove strong dependencies
• Easier to test
• Write highly abstract processes
Stateless objects
Stateless
Statefull
Why?
• No setup
• Predictable
Domain Specific Language
Router Controller
Domain
API language
Domain Specific Language
View API language
Break down
Request Router Controller
ResponseView
Application
?
??
??
Models
Services
Application
Forms Policies
Queries Adapters Models
Services Forms Policies
Queries Adapters Models
Application
Services (1)
Describe processes
Services (2)
Services (3)
Services (4)
Create != Signup
Services (5)
Services (6)
Services (7)
Services (8)
User::SignupService
Payment::SignupService
user/signup_service_spec
Payment::SignupService
payment/signup_service_spec
Services Forms Policies
Queries Adapters Models
Application
Forms (1)
Convert inputs in
Domain language
Forms (2)
USER
email
password
Forms (3)
Forms (4)
Forms (5)
Forms (6)
User
email
password
User::Profile
user_id
first_name
last_name
User
email
password
first_name
last_name
Forms (7)
accepts_nested_attributes_for
Forms (8)
Forms (9)
Forms (10)
Services Forms Policies
Queries Adapters Models
Application
Policies (1)
Describe permissions
Policies (2)
Policies (3)
Policies (4)
Services Forms Policies
Queries Adapters Models
Application
Queries (1)
Describe how to access data
Queries (2)
Queries (3)
Services Forms Policies
Queries Adapters Models
Application
Adapters (1)
Translate DSL into another
Adapters (2)
User
email
password
first_name
last_name
Recurly
Adapters (3)
Adapters (4)
It’s about languages
Adapters (5)
3rd party
API language
Client
Http request
Ruby method
Adapters (6)
Client
API Language
Adapter
DSL
Application
Adapters (7)
Adapters (8)
PaymentManager
RecurlyAdapter StripeAdapter
Benefits
• Easy to test (mock client responses)
• New provider => new adapter
• Easy to migrate
• Fake adapters for integration servers
Services Forms Policies
Queries Adapters Models
Application
Models (1)
Data
(& persistency)
Models (2)
If it doesn’t fit in models
…
Models (3)
Then it doesn’t fit in models!
Models (4)
Conclusion
It’s not a perfect solution,
just a guide
Pros
• Easier to browse and discover
• More flexible
• Easier to test
• Easier to debug
• Agnostic (from ActiveRecord)
after_commit
Cons
• Harder to design
• More time on code architecture
• Write more code, more tests
• Write integration tests (IOC)
Small apps
Soft transition
• Code convention
• Focus on data and API
• Express everything in DSL
• Write adapters early
• Drop assets pipeline
• Split FE / BE in different projects
Big apps
More tips
• If it doesn’t fit anywhere, think twice
• If it still doesn’t fit anywhere, you need a new layer
• Check what Java / React community does
Rails
is a fantastic prototyping tool!
Rails
is NOT an application framework
Rails
is a fantastic web framework!
Thank you!
Q & A
1 of 106

Recommended

RubyConf China 2015 - Rails off assets pipeline by
RubyConf China 2015 - Rails off assets pipelineRubyConf China 2015 - Rails off assets pipeline
RubyConf China 2015 - Rails off assets pipelineFlorian Dutey
199 views70 slides
Beyond The Rails Way by
Beyond The Rails WayBeyond The Rails Way
Beyond The Rails WayAndrzej Krzywda
3.5K views35 slides
From Rails legacy to DDD - Pivorak, Lviv by
From Rails legacy to DDD - Pivorak, LvivFrom Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivAndrzej Krzywda
1.7K views68 slides
Refactoring Rails applications with RubyMine by
Refactoring Rails applications with RubyMineRefactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMineAndrzej Krzywda
1K views33 slides
Performance and Abstractions by
Performance and AbstractionsPerformance and Abstractions
Performance and AbstractionsMetosin Oy
1.1K views54 slides
Craft Beer & Clojure by
Craft Beer & ClojureCraft Beer & Clojure
Craft Beer & ClojureMetosin Oy
403 views18 slides

More Related Content

What's hot

Signal r azurepresentation by
Signal r azurepresentationSignal r azurepresentation
Signal r azurepresentationJustin Wendlandt
901 views21 slides
Migrate PHP E-Commerce Site to Go by
Migrate PHP E-Commerce Site to GoMigrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to GoWeng Wei
1.8K views32 slides
Angular4 kickstart by
Angular4 kickstartAngular4 kickstart
Angular4 kickstartFoyzul Karim
549 views24 slides
TypeScript and Angular2 (Love at first sight) by
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)Igor Talevski
503 views26 slides
Why use Go for web development? by
Why use Go for web development?Why use Go for web development?
Why use Go for web development?Weng Wei
3.6K views57 slides
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA... by
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA....NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...Christian Nagel
166 views12 slides

What's hot(20)

Migrate PHP E-Commerce Site to Go by Weng Wei
Migrate PHP E-Commerce Site to GoMigrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to Go
Weng Wei1.8K views
TypeScript and Angular2 (Love at first sight) by Igor Talevski
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)
Igor Talevski503 views
Why use Go for web development? by Weng Wei
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
Weng Wei3.6K views
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA... by Christian Nagel
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA....NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
Christian Nagel166 views
Orleans – a “cloud native” runtime built for #azure by Brisebois
Orleans – a “cloud native” runtime built for #azureOrleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azure
Brisebois1.5K views
C# 9 - What's the cool stuff? - BASTA! Spring 2021 by Christian Nagel
C# 9 - What's the cool stuff? - BASTA! Spring 2021C# 9 - What's the cool stuff? - BASTA! Spring 2021
C# 9 - What's the cool stuff? - BASTA! Spring 2021
Christian Nagel56 views
Metaprogramming Go by Weng Wei
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
Weng Wei7K views
Porting ASP.NET applications to Windows Azure by Gunnar Peipman
Porting ASP.NET applications to Windows AzurePorting ASP.NET applications to Windows Azure
Porting ASP.NET applications to Windows Azure
Gunnar Peipman543 views
Fast Web Applications with Go by Eylem Ozekin
Fast Web Applications with Go Fast Web Applications with Go
Fast Web Applications with Go
Eylem Ozekin1.3K views
Unit Testing in JavaScript by Rob Scaduto
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScript
Rob Scaduto544 views
Ohio Devfest - Visual Analysis with GCP by Wesley Workman
Ohio Devfest - Visual Analysis with GCPOhio Devfest - Visual Analysis with GCP
Ohio Devfest - Visual Analysis with GCP
Wesley Workman60 views
Entity Framework Core 1.x/2.x Advanced by Christian Nagel
Entity Framework Core 1.x/2.x AdvancedEntity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x Advanced
Christian Nagel313 views
Relay: Seamless Syncing for React (VanJS) by Brooklyn Zelenka
Relay: Seamless Syncing for React (VanJS)Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)
Brooklyn Zelenka1.5K views

Similar to RubyConf Taiwan 2016 - Large scale Rails applications

21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir by
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
21o. RubyFloripa - Maintaining legacy Rails app and introducing ElixirWeverton Timoteo
522 views37 slides
Phoenix for Rubyists by
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for RubyistsDoug Goldie
109 views46 slides
2010-07-19_rails_tdd_week1 by
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1Wolfram Arnold
986 views33 slides
Building scalable applications with angular js by
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular jsAndrew Alpert
13.4K views46 slides
Api chaining(tm) by
Api chaining(tm)Api chaining(tm)
Api chaining(tm)Owen Rubel
3.2K views38 slides
Domain oriented development by
Domain oriented developmentDomain oriented development
Domain oriented developmentrajmundr
651 views35 slides

Similar to RubyConf Taiwan 2016 - Large scale Rails applications(20)

21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir by Weverton Timoteo
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
Weverton Timoteo522 views
Phoenix for Rubyists by Doug Goldie
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for Rubyists
Doug Goldie109 views
Building scalable applications with angular js by Andrew Alpert
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
Andrew Alpert13.4K views
Api chaining(tm) by Owen Rubel
Api chaining(tm)Api chaining(tm)
Api chaining(tm)
Owen Rubel3.2K views
Domain oriented development by rajmundr
Domain oriented developmentDomain oriented development
Domain oriented development
rajmundr651 views
Testing for Logic App Solutions | Integration Monday by BizTalk360
Testing for Logic App Solutions | Integration MondayTesting for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration Monday
BizTalk360373 views
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa... by Web Tech Fun
Oleksandr Khotemskyi  - Serverless architecture and how to apply it in Automa...Oleksandr Khotemskyi  - Serverless architecture and how to apply it in Automa...
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa...
Web Tech Fun 23 views
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац... by Dakiry
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Dakiry81 views
Client Technical Analysis of Legacy Software and Future Replacement by VictorSzoltysek
Client Technical Analysis of Legacy Software and Future ReplacementClient Technical Analysis of Legacy Software and Future Replacement
Client Technical Analysis of Legacy Software and Future Replacement
VictorSzoltysek113 views
Scala io2013 : Our journey from UML/MDD to Scala macros by ebiznext
Scala io2013 : Our journey from UML/MDD to Scala macrosScala io2013 : Our journey from UML/MDD to Scala macros
Scala io2013 : Our journey from UML/MDD to Scala macros
ebiznext4.9K views
REST and REST-fulness by David Waite
REST and REST-fulnessREST and REST-fulness
REST and REST-fulness
David Waite1.1K views
JDD2014: REST API versioning practice: from header to model - Łukasz Wierzbicki by PROIDEA
JDD2014: REST API versioning practice: from header to model - Łukasz WierzbickiJDD2014: REST API versioning practice: from header to model - Łukasz Wierzbicki
JDD2014: REST API versioning practice: from header to model - Łukasz Wierzbicki
PROIDEA442 views
From ddd to DDD : My journey from data-driven development to Domain-Driven De... by Thibaud Desodt
From ddd to DDD : My journey from data-driven development to Domain-Driven De...From ddd to DDD : My journey from data-driven development to Domain-Driven De...
From ddd to DDD : My journey from data-driven development to Domain-Driven De...
Thibaud Desodt520 views
Алексей Веркеенко "Symfony2 & REST API" by Fwdays
Алексей Веркеенко "Symfony2 & REST API" Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API"
Fwdays2K views
Functional solid by Matt Stine
Functional solidFunctional solid
Functional solid
Matt Stine2.7K views
APIs distribuidos con alta escalabilidad by Software Guru
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
Software Guru1.9K views

Recently uploaded

sam_software_eng_cv.pdf by
sam_software_eng_cv.pdfsam_software_eng_cv.pdf
sam_software_eng_cv.pdfsammyigbinovia
10 views5 slides
Ansari: Practical experiences with an LLM-based Islamic Assistant by
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic AssistantM Waleed Kadous
9 views29 slides
REACTJS.pdf by
REACTJS.pdfREACTJS.pdf
REACTJS.pdfArthyR3
37 views16 slides
MK__Cert.pdf by
MK__Cert.pdfMK__Cert.pdf
MK__Cert.pdfHassan Khan
19 views1 slide
Web Dev Session 1.pptx by
Web Dev Session 1.pptxWeb Dev Session 1.pptx
Web Dev Session 1.pptxVedVekhande
17 views22 slides
_MAKRIADI-FOTEINI_diploma thesis.pptx by
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptxfotinimakriadi
12 views32 slides

Recently uploaded(20)

Ansari: Practical experiences with an LLM-based Islamic Assistant by M Waleed Kadous
Ansari: Practical experiences with an LLM-based Islamic AssistantAnsari: Practical experiences with an LLM-based Islamic Assistant
Ansari: Practical experiences with an LLM-based Islamic Assistant
M Waleed Kadous9 views
REACTJS.pdf by ArthyR3
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR337 views
Web Dev Session 1.pptx by VedVekhande
Web Dev Session 1.pptxWeb Dev Session 1.pptx
Web Dev Session 1.pptx
VedVekhande17 views
_MAKRIADI-FOTEINI_diploma thesis.pptx by fotinimakriadi
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptx
fotinimakriadi12 views
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth by Innomantra
BCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for GrowthBCIC - Manufacturing Conclave -  Technology-Driven Manufacturing for Growth
BCIC - Manufacturing Conclave - Technology-Driven Manufacturing for Growth
Innomantra 15 views
SUMIT SQL PROJECT SUPERSTORE 1.pptx by Sumit Jadhav
SUMIT SQL PROJECT SUPERSTORE 1.pptxSUMIT SQL PROJECT SUPERSTORE 1.pptx
SUMIT SQL PROJECT SUPERSTORE 1.pptx
Sumit Jadhav 22 views
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx by lwang78
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
2023Dec ASU Wang NETR Group Research Focus and Facility Overview.pptx
lwang78180 views
Créativité dans le design mécanique à l’aide de l’optimisation topologique by LIEGE CREATIVE
Créativité dans le design mécanique à l’aide de l’optimisation topologiqueCréativité dans le design mécanique à l’aide de l’optimisation topologique
Créativité dans le design mécanique à l’aide de l’optimisation topologique
LIEGE CREATIVE8 views
MongoDB.pdf by ArthyR3
MongoDB.pdfMongoDB.pdf
MongoDB.pdf
ArthyR349 views

RubyConf Taiwan 2016 - Large scale Rails applications