Date post: | 21-Dec-2014 |
Category: |
Technology |
Upload: | gavinjoyce |
View: | 402 times |
Download: | 1 times |
@gavinjoyce
Taming Monolithic Monsters
What’s the Problem?
What’s the Problem?● Rails apps don’t scale
What’s the Problem?● Rails apps don’t scale● Rails apps do scale:
What’s the Problem?● Rails apps don’t scale● Rails apps do scale:
○ Web servers are cheap
What’s the Problem?● Rails apps don’t scale● Rails apps do scale:
○ Web servers are cheap○ Engineers are expensive
What’s the Problem?● Rails apps don’t scale● Rails apps do scale:
○ Web servers are cheap○ Engineers are expensive○ Rails is optimised to save engineering time
What’s the Problem?● Rails apps don’t scale● Rails apps do scale:
○ Web servers are cheap○ Engineers are expensive○ Rails is optimised to save engineering time○ not the full story...
What’s the Problem?
● Large rails apps are hard to scale
In my experience:
What’s the Problem?
● Large rails apps are hard to scale:○ Team size
In my experience:
What’s the Problem?
● Large rails apps are hard to scale:○ Team size
■ code base complexity
In my experience:
What’s the Problem?
● Large rails apps are hard to scale:○ Team size
■ code base complexity■ brittleness due to tight coupling between
models
In my experience:
What’s the Problem?
● Large rails apps are hard to scale:○ Team size
■ code base complexity■ brittleness due to tight coupling between
models○ TDD feedback time
In my experience:
Mutations Gemgithub.com/cypriss/mutations
● Compose your business logic into commands that sanitize and validate input
Mutations Gemgithub.com/cypriss/mutations
● Compose your business logic into commands that sanitize and validate input
● Write safe, reusable, and maintainable code for Ruby and Rails apps
Defining a Mutations Command
Using a Mutations Command
demo - simple mutation command
Mutations in your app
Mutations in your app
● create an internal api
Mutations in your app
● create an internal api○ logically isolate key business logic
Mutations in RestPack
Mutations in RestPack
https://github.com/restpack
Mutations in RestPack
Mutations in RestPack
● Services are packaged as gems
Mutations in RestPack
● Services are packaged as gems:○ Commands
Mutations in RestPack
● Services are packaged as gems:○ Commands○ Serialisers
Mutations in RestPack
● Services are packaged as gems:○ Commands○ Serialisers○ Models
Mutations in RestPack
● Services are packaged as gems:○ Commands○ Serialisers○ Models○ Migrations
Mutations in RestPack
● Services are packaged as gems:○ Commands○ Serialisers○ Models○ Migrations○ Specs
Mutations in RestPack
● Services are packaged as gems:○ Commands○ Serialisers○ Models○ Migrations○ Specs
● Commands are the public interface
Mutations in RestPack
● Services are packaged as gems:○ Commands○ Serialisers○ Models○ Migrations○ Specs
● Commands are the public interface○ either Ruby or REST
RestPack Service Gem Anatomy
DB
RestPack Service Gem Anatomy
DB
RestPack Service Gem Anatomy
rake restpack:migrate
DB
models
RestPack Service Gem Anatomy
rake restpack:migrate
DB
models
RestPack Service Gem Anatomy
ActiveRecord models
rake restpack:migrate
DB
models
serialisers
RestPack Service Gem Anatomy
rake restpack:migrate
ActiveRecord models
DB
models
serialisers
RestPack Service Gem Anatomy
RestPack::Serializer gem
rake restpack:migrate
ActiveRecord models
DB
models
serialisers
commands
RestPack Service Gem Anatomy
rake restpack:migrate
ActiveRecord models
RestPack::Serializer gem
DB
models
serialisers
commands
RestPack Service Gem Anatomy
Mutations gem
rake restpack:migrate
ActiveRecord models
RestPack::Serializer gem
RestPack Service Gem Anatomy
code demo - restpack_activity_service
https://github.com/RestPack/restpack_activity_service
Using service gems from Rails
A first attempt….
DB
Activity Service Gem
actv.io rails app
DB
Activity Controller
Activity Service Gem
Host Ruby Application
actv.io rails app
DB
Activity Controller
Activity Clent Gem
Activity Service Gem
Host Ruby Application
actv.io rails app
Activity Model
DB
Activity Controller
Activity Clent Gem
Activity Service Gem
Host Ruby Application
actv.io rails app
Activity Model
Local Proxy
DB
Activity Controller
Activity Clent Gem
Activity Service Gem
Host Ruby Application
actv.io rails app
Activity Model
API ProxyLocal Proxy
DB
API
REST
Activity Controller
Activity Clent Gem
Activity Service Gem
Host Ruby Application
demo - Rails App
actv.io rails app
Activity Model
API ProxyLocal Proxy
DB
API
REST
Activity Controller
Activity Clent Gem
Activity Service Gem
Host Ruby Application
No need for Rails, the API is the server application
API
No need for Rails, the API is the server application
Android App
API
No need for Rails, the API is the server application
Android App iOS App
API
No need for Rails, the API is the server application
Web App Android App iOS App
API
No need for Rails, the API is the server application
Web App Android App iOS App ... App
API
... App... App
api.restpack.org
Core
DB
api.restpack.org
DB DB
Core Users
api.restpack.org
DB DB DB
Core Users Groups
api.restpack.org
DB DB DB DB
Core Users Groups Account
api.restpack.org
DB DB DB DB DB
Core Users Groups Account Email
Redis
Job Q
api.restpack.org
DB DB DB DB DB
Core Users Groups Account Email
Redis
Job Q
api.restpack.orgApply Security Policy
DB DB DB DB DB
Core Users Groups Account Email
Redis
Job Q
api.restpack.org
dashboard.restpack.org
Apply Security Policy
DB DB DB DB DB
Core Users Groups Account Email
Redis
Job Q
api.restpack.org
dashboard.restpack.org
Apply Security Policy
3rd Party Applications3rd Party Applications
3rd Party Applications3rd Party Applications
demo - Ember.js App
Redis
Job Q
api.restpack.org
dashboard.restpack.org
DB
1 Application, 1 DB
DB DB DB DB DB
Core Users Groups Account Email
Redis
Job Q
api.restpack.org
dashboard.restpack.org
API
Apply Security Policy
API APIAPI API
Many Applications, Many DBs
@gavinjoycegithub.com/RestPack
Questions?