Taming Monolithic Monsters

@gavinjoyce
Need help building
something ambitious?
gavinjoyce@gmail.com
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
○ Ra...
What’s the Problem?
● Rails apps don’t scale
● Rails apps do scale:
○ Web servers are cheap
○ Engineers are expensive
○ Ra...
What’s the Problem?
In my experience:
● Large rails apps are hard to scale
What’s the Problem?
In my experience:
● Large rails apps are hard to scale:
○ Team size
What’s the Problem?
In my experience:
● Large rails apps are hard to scale:
○ Team size
■ code base complexity
What’s the Problem?
In my experience:
● Large rails apps are hard to scale:
○ Team size
■ code base complexity
■ brittlene...
What’s the Problem?
In my experience:
● Large rails apps are hard to scale:
○ Team size
■ code base complexity
■ brittlene...
Mutations Gem
github.com/cypriss/mutations
Mutations Gem
github.com/cypriss/mutations

● Compose your business logic into
commands that sanitize and validate input
Mutations Gem
github.com/cypriss/mutations

● Compose your business logic into
commands that sanitize and validate input
●...
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 a...
Mutations in RestPack
● Services are packaged as gems:
○ Commands
○ Serialisers
○ Models
○ Migrations
○ Specs
● Commands a...
RestPack Service Gem Anatomy
RestPack Service Gem Anatomy

DB
RestPack Service Gem Anatomy

rake restpack:migrate
DB
RestPack Service Gem Anatomy

models

rake restpack:migrate
DB
RestPack Service Gem Anatomy

models

ActiveRecord models

rake restpack:migrate
DB
RestPack Service Gem Anatomy

serialisers

models

ActiveRecord models

rake restpack:migrate
DB
RestPack Service Gem Anatomy

serialisers

RestPack::Serializer gem

models

ActiveRecord models

rake restpack:migrate
DB
RestPack Service Gem Anatomy
commands

serialisers

RestPack::Serializer gem

models

ActiveRecord models

rake restpack:m...
RestPack Service Gem Anatomy
commands

Mutations gem

serialisers

RestPack::Serializer gem

models

ActiveRecord models

...
RestPack Service Gem Anatomy

code demo - restpack_activity_service
https://github.com/RestPack/restpack_activity_service
Using service gems from Rails

A first attempt….
Activity Service Gem

DB
actv.io rails app
Activity Controller

Host Ruby Application

Activity Service Gem

DB
actv.io rails app
Activity Controller

Host Ruby Application

Activity Clent Gem

Activity Service Gem

DB
actv.io rails app
Activity Controller

Activity Model

Host Ruby Application

Activity Clent Gem

Activity Service Gem

DB
actv.io rails app
Activity Controller

Activity Model

Host Ruby Application

Activity Clent Gem

Local Proxy

Activity Se...
actv.io rails app

Host Ruby Application

Activity Controller

Activity Model

Local Proxy

Activity Clent Gem
API Proxy
R...
demo - Rails App
actv.io rails app

Host Ruby Application

Activity Controller

Activity Model

Local Proxy

Activity Clent Gem
API Proxy
R...
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

API

... App
... App
... App
api.restpack.org
api.restpack.org

DB
Core
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

Job
Q

DB

DB

DB

DB

DB

Core

Users

Groups

Account

Email

Redis
Apply Security Policy
api.restpack.org

Job
Q

DB

DB

DB

DB

DB

Core

Users

Groups

Account

Email

Redis
dashboard.restpack.org

Apply Security Policy
api.restpack.org

Job
Q

DB

DB

DB

DB

DB

Core

Users

Groups

Account

E...
3rd Party Applications
3rd Party Applications
3rd Party Applications
3rd Party Applications

dashboard.restpack.org

Apply...
demo - Ember.js App
1 Application, 1 DB

dashboard.restpack.org

api.restpack.org

Job
Q

DB

Redis
Many Applications, Many DBs

dashboard.restpack.org

Apply Security Policy

api.restpack.org

API

API

API

API

API

Job...
Questions?

@gavinjoyce
github.com/RestPack
Upcoming SlideShare
Loading in …5
×

Taming monolithic monsters

937 views
786 views

Published on

The slides from my presentation to RubyIreland

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
937
On SlideShare
0
From Embeds
0
Number of Embeds
58
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Taming monolithic monsters

  1. 1. Taming Monolithic Monsters @gavinjoyce
  2. 2. Need help building something ambitious? gavinjoyce@gmail.com
  3. 3. What’s the Problem?
  4. 4. What’s the Problem? ● Rails apps don’t scale
  5. 5. What’s the Problem? ● Rails apps don’t scale ● Rails apps do scale:
  6. 6. What’s the Problem? ● Rails apps don’t scale ● Rails apps do scale: ○ Web servers are cheap
  7. 7. What’s the Problem? ● Rails apps don’t scale ● Rails apps do scale: ○ Web servers are cheap ○ Engineers are expensive
  8. 8. 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
  9. 9. 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...
  10. 10. What’s the Problem? In my experience: ● Large rails apps are hard to scale
  11. 11. What’s the Problem? In my experience: ● Large rails apps are hard to scale: ○ Team size
  12. 12. What’s the Problem? In my experience: ● Large rails apps are hard to scale: ○ Team size ■ code base complexity
  13. 13. What’s the Problem? In my experience: ● Large rails apps are hard to scale: ○ Team size ■ code base complexity ■ brittleness due to tight coupling between models
  14. 14. What’s the Problem? In my experience: ● Large rails apps are hard to scale: ○ Team size ■ code base complexity ■ brittleness due to tight coupling between models ○ TDD feedback time
  15. 15. Mutations Gem github.com/cypriss/mutations
  16. 16. Mutations Gem github.com/cypriss/mutations ● Compose your business logic into commands that sanitize and validate input
  17. 17. Mutations Gem github.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
  18. 18. Defining a Mutations Command
  19. 19. Using a Mutations Command
  20. 20. demo - simple mutation command
  21. 21. Mutations in your app
  22. 22. Mutations in your app ● create an internal api
  23. 23. Mutations in your app ● create an internal api ○ logically isolate key business logic
  24. 24. Mutations in RestPack
  25. 25. Mutations in RestPack https://github.com/restpack
  26. 26. Mutations in RestPack
  27. 27. Mutations in RestPack ● Services are packaged as gems
  28. 28. Mutations in RestPack ● Services are packaged as gems: ○ Commands
  29. 29. Mutations in RestPack ● Services are packaged as gems: ○ Commands ○ Serialisers
  30. 30. Mutations in RestPack ● Services are packaged as gems: ○ Commands ○ Serialisers ○ Models
  31. 31. Mutations in RestPack ● Services are packaged as gems: ○ Commands ○ Serialisers ○ Models ○ Migrations
  32. 32. Mutations in RestPack ● Services are packaged as gems: ○ Commands ○ Serialisers ○ Models ○ Migrations ○ Specs
  33. 33. Mutations in RestPack ● Services are packaged as gems: ○ Commands ○ Serialisers ○ Models ○ Migrations ○ Specs ● Commands are the public interface
  34. 34. Mutations in RestPack ● Services are packaged as gems: ○ Commands ○ Serialisers ○ Models ○ Migrations ○ Specs ● Commands are the public interface ○ either Ruby or REST
  35. 35. RestPack Service Gem Anatomy
  36. 36. RestPack Service Gem Anatomy DB
  37. 37. RestPack Service Gem Anatomy rake restpack:migrate DB
  38. 38. RestPack Service Gem Anatomy models rake restpack:migrate DB
  39. 39. RestPack Service Gem Anatomy models ActiveRecord models rake restpack:migrate DB
  40. 40. RestPack Service Gem Anatomy serialisers models ActiveRecord models rake restpack:migrate DB
  41. 41. RestPack Service Gem Anatomy serialisers RestPack::Serializer gem models ActiveRecord models rake restpack:migrate DB
  42. 42. RestPack Service Gem Anatomy commands serialisers RestPack::Serializer gem models ActiveRecord models rake restpack:migrate DB
  43. 43. RestPack Service Gem Anatomy commands Mutations gem serialisers RestPack::Serializer gem models ActiveRecord models rake restpack:migrate DB
  44. 44. RestPack Service Gem Anatomy code demo - restpack_activity_service https://github.com/RestPack/restpack_activity_service
  45. 45. Using service gems from Rails A first attempt….
  46. 46. Activity Service Gem DB
  47. 47. actv.io rails app Activity Controller Host Ruby Application Activity Service Gem DB
  48. 48. actv.io rails app Activity Controller Host Ruby Application Activity Clent Gem Activity Service Gem DB
  49. 49. actv.io rails app Activity Controller Activity Model Host Ruby Application Activity Clent Gem Activity Service Gem DB
  50. 50. actv.io rails app Activity Controller Activity Model Host Ruby Application Activity Clent Gem Local Proxy Activity Service Gem DB
  51. 51. actv.io rails app Host Ruby Application Activity Controller Activity Model Local Proxy Activity Clent Gem API Proxy REST API Activity Service Gem DB
  52. 52. demo - Rails App
  53. 53. actv.io rails app Host Ruby Application Activity Controller Activity Model Local Proxy Activity Clent Gem API Proxy REST API Activity Service Gem DB
  54. 54. No need for Rails, the API is the server application API
  55. 55. No need for Rails, the API is the server application Android App API
  56. 56. No need for Rails, the API is the server application Android App iOS App API
  57. 57. No need for Rails, the API is the server application Web App Android App iOS App API
  58. 58. No need for Rails, the API is the server application Web App Android App iOS App API ... App ... App ... App
  59. 59. api.restpack.org
  60. 60. api.restpack.org DB Core
  61. 61. api.restpack.org DB DB Core Users
  62. 62. api.restpack.org DB DB DB Core Users Groups
  63. 63. api.restpack.org DB DB DB DB Core Users Groups Account
  64. 64. api.restpack.org Job Q DB DB DB DB DB Core Users Groups Account Email Redis
  65. 65. Apply Security Policy api.restpack.org Job Q DB DB DB DB DB Core Users Groups Account Email Redis
  66. 66. dashboard.restpack.org Apply Security Policy api.restpack.org Job Q DB DB DB DB DB Core Users Groups Account Email Redis
  67. 67. 3rd Party Applications 3rd Party Applications 3rd Party Applications 3rd Party Applications dashboard.restpack.org Apply Security Policy api.restpack.org Job Q DB DB DB DB DB Core Users Groups Account Email Redis
  68. 68. demo - Ember.js App
  69. 69. 1 Application, 1 DB dashboard.restpack.org api.restpack.org Job Q DB Redis
  70. 70. Many Applications, Many DBs dashboard.restpack.org Apply Security Policy api.restpack.org API API API API API Job Q DB DB DB DB DB Core Users Groups Account Email Redis
  71. 71. Questions? @gavinjoyce github.com/RestPack

×