Slide 1

Slide 1 text

Building Modular Apps with Ruby & AWS Kyle Fox / @kylefox YEGRB / November 20, 2012

Slide 2

Slide 2 text

Carbonmade in a nutshell • Artists signup & build a portfolio (back-end) • People visit artists’ portfolios (front-end)

Slide 3

Slide 3 text

Artist Manage Portfolio Visitors View Portfolio Monolith! Massive .NET app & database server Admin Junk Reports, customer support, etc.

Slide 4

Slide 4 text

The Problems I got 99 problems and they’re all architecture related.

Slide 5

Slide 5 text

Massive Rackspace Server • Dedicated = Expensive • Slow to provision new hardware • Resource contention

Slide 6

Slide 6 text

Monolithic Design • Single point of failure • Bottleneck is EVERYTHING • Break once, break everywhere • Tight coupling = house of cards

Slide 7

Slide 7 text

Workflow Issues • Hard to find .NET developers • Editing files over FTP • Deploys required compilation, or something dumb like that • Difficult to write tests

Slide 8

Slide 8 text

what to do?

Slide 9

Slide 9 text

let’s try a SERVICE ORIENTED ARCHITECTURE

Slide 10

Slide 10 text

A fancy way of saying Let’s break the app into a bunch of isolated, single-responsibility components! And have them work together over black-box APIs. Amazon’s Web Services are great for this purpose.

Slide 11

Slide 11 text

Advantages of a SOA • Avoids a single point of failure • Easier to scale parts that need scaling • Makes infrastructure refactoring a breeze • Decoupled by design • Easier to rebuild in phases than all at once

Slide 12

Slide 12 text

AWS we’ll use • Elastic Compute Cloud (EC2) • Server Virtualization & Load Balancing • Simple Storage Service (S3) • Persistent Data Storage • CloudFront (CF) • Content Delivery Network • Simple Queue Service (SQS) • Message Queue • Simple Notification Service (SNS) • Broadcast Notifications (pubsub)

Slide 13

Slide 13 text

Step #1 Remove public portfolio rendering from monolithic .NET app

Slide 14

Slide 14 text

Visitors View Portfolio .NET Database & Back-end tools Sinatra •EC2 •Stateless (no database) •Reads from API •Renders data in Liquid templates Get /projects/123 {project: ... }

Slide 15

Slide 15 text

Good things • Moved some traffic off back-end • Designed an API • Moved templates to Liquid! • Git & automated deployment

Slide 16

Slide 16 text

Bad things • Single point of failure • No caching • No failover / redundancy • App logic (data fetching & theme rendering) is embedded in a web framework. Gross.

Slide 17

Slide 17 text

Step #2 Many Sinatra apps & carbonmade gem

Slide 18

Slide 18 text

EC2 Load Balancer Visitors View Portfolio .NET Database & Back-end tools Sinatra Sinatra Sinatra Cache Huge membase cluster Carbonmade Gem High-memory EC2 instances Multiple Portfolio Servers

Slide 19

Slide 19 text

EC2 Load Balancer Visitors View Portfolio .NET Database & Back-end tools Sinatra Sinatra Sinatra Cache Huge membase cluster Carbonmade Gem Amazon SQS Cache invalidation messages Queue message when portfolio updated Poll for messages Delete from cache Cache Invalidation

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Step #3 Build a Theme Park ...wait, huh?

Slide 22

Slide 22 text

Designers shouldn’t need to deploy to server clusters When all they’re doing is changing some CSS

Slide 23

Slide 23 text

...well, they should but they refused.

Slide 24

Slide 24 text

In the land of the noble beaver where the rivers run wild with maple syrup, there lives a ne young gentleman named Kyle Fox. He's been developing nifty things for us in the moose-plagued landscape of Edmonton, Alberta since the beginning of 2011. At present he is working his sweet magic on our iPad app while wrestling bears, sipping ne Canadian whiskeys and tapping every last maple tree. We raise our glasses in celebration of his big day and thank him for being such a funny and valued member of Team Carbonmade. Happy birthday, eh?

Slide 25

Slide 25 text

Theme Park • A web-based tool for editing themes • Writes files (HTML/CSS/JS) directly to S3 • Asset bundling • Versioning • Deployments

Slide 26

Slide 26 text

ThemePark Online Editor Amazon S3 Used as CloudFront origin HTML CSS JS Liquid Files theme--.zip Publishing a theme

Slide 27

Slide 27 text

ThemePark Online Editor Amazon S3 Used as CloudFront origin HTML CSS JS Liquid Files theme--.zip Amazon SNS Theme Updated! Post to SNS

Slide 28

Slide 28 text

ThemePark Online Editor Amazon S3 Used as CloudFront origin HTML CSS JS Liquid Files theme--.zip Amazon SNS Theme Updated! Post to SNS Sinatra Sinatra Sinatra Theme Updated! Notify Subscribers

Slide 29

Slide 29 text

ThemePark Online Editor Amazon S3 Used as CloudFront origin HTML CSS JS Liquid Files theme--.zip Amazon SNS Theme Updated! Post to SNS Sinatra Sinatra Sinatra Theme Updated! Notify Subscribers Download templates

Slide 30

Slide 30 text

Publishing an SNS Message

Slide 31

Slide 31 text

Receiving an SNS Message

Slide 32

Slide 32 text

In conclusion Breaking up apps: • Makes testing & refactoring easier • Let’s you scale components individually & appropriately • Gives you freedom to drastically change how pieces work • Makes fault-tolerance & failover easier • AWS is a cheap & easy way to do this!