Implementing Rails 3.1, Backbone.js, CoffeeScript ... - OpenLogic

bolivialodgeInternet and Web Development

Dec 14, 2013 (3 years and 8 months ago)

93 views

Implementing
Rails 3.1,
Backbone.js
,
CoffeeScript
,
jQuery
, Sass, and CouchDB on EC2

Rod Cope, CTO & Founder
OpenLogic, Inc.
OpenLogic, Inc.
Agenda
!

Introduction
!

Background
!

Problems
!

Approach
!

Technologies
!

Final Thoughts
!

Q & A
2
OpenLogic, Inc.
Introduction
!

Rod Cope
!

CTO & Founder of OpenLogic
!

25+ years of software development experience
!

IBM Global Services, Anthem, General Electric
!

Currently writing “Cloud Computing in Action: Innovating with
Open Source” for Manning (“cloudc40”)
!

OpenLogic
!

Open Source Provisioning, Support, and Governance Solutions
!

Certified library w/SLA support on 650+ Open Source packages
!
http://olex.openlogic.com
!

Over 250 Enterprise customers
3
OpenLogic, Inc.
Background
!

OpenLogic CloudSwing – “Open
PaaS

!

Deploy, manage, monitor, and support open source stacks on
public and private clouds
!

Multiple deployment targets (
EC2
,
Rackspace
,
OpenStack
, etc.)
!

Multiple web servers (
Apache
,
Nginx
, etc.)
!

Multiple languages & frameworks (
Java
,
Ruby
,
PHP
, etc.)
!

Multiple data stores (
MySQL
,
PostgreSQL
, Redis, HBase, etc.)
!

Multiple operating systems (
Ubuntu
, CentOS, etc.)
!

Crunch time
!

Re-implement prototype from scratch on new tech
!

Zero to production in 2 months
4
OpenLogic, Inc.
Problems
!

Lots of excitement around prototype
!

Won the Cloud Connect competition in March
!

Serious interest from Fortune 500 customers & prospects
!

Marketing & Sales ready to go before first line of code written
!

Existing
SaaS
products on older tech
!

Rails 2.3, Prototype (some
jQuery
), Redis, MySQL 5.1
!

No public cloud hosting experience
!

Can’t drop everything
!

Still supporting & growing existing products
!

New customers want new features
5
OpenLogic, Inc.
Approach
!

Partition team
!

Roughly half on existing products, half on new product
!

Got lucky: team members self-selected into perfect split
!

Jumped into the deep end
!

Just-in-time scouting on key pieces
!

UI design, Rails 3.1,
CoffeeScript
, CouchDB,
asset pipeline, security (mainly encryption in
transit and at rest)
!

Agile process tweaks
!

Feature sets vs. stories
!

Split out
DevOps

!

DNS, SSL certificates, email management
!

Deployment, monitoring, configuration, load balancing, asset pipeline
6
OpenLogic, Inc.
The Tech: What is all this stuff?
!

Rails 3.1
!

Page streaming, asset pipeline, Rack Cache/
Etag
/
ConditionalGet
, Engines
!

Sass,
jQuery
, and
CoffeeScript
by default
!

Great for us because we already decided on all 3 with Rails 3.0
!
Backbone.js

!

Lightweight client-side MVC
!
CoffeeScript

!

Scripting language that translates to pure JavaScript, flavors of Ruby & Python
!
jQuery

!

De facto standard JavaScript library for modern web apps
!

Sass
!

Superset of CSS3 with variables, functions, overrides,
DRYness

!

CouchDB
!

Document store with map/reduce views, safe shutdown via “kill -9”

7
OpenLogic, Inc.
The Tech




P r o s, C o n s, a n d W T F ’ s
8
OpenLogic, Inc.
Rails 3.1
9

OpenLogic, Inc.
10
Rails 3.1
OpenLogic, Inc.
Rails 3.1
!

Two weeks go by
!

Then two more weeks
!

Then two more weeks
!

Then two more weeks
!

Then two more weeks
!

3.1.0 final released on Wednesday,
August 31st
!

Well after our first beta release to production

11
OpenLogic, Inc.
Rails 3.1
!

Bundler – a love/hate relationship
!

“Great”, “terrible”, “pain in the ass”,
“makes things easy”
!

“Tries to be too smart and fails miserably”
!


Gemfile
,
Gemfile.lock
, and DSL are good, rest is bad”
!


git
repo usage is both great and terrible at the same time”

12
OpenLogic, Inc.
Rails 3.1 (cont.)
!

Lots of improvements for
ActiveRecord

!

Doesn’t help CouchDB, but split out of
ActiveModel
is good
!

Sprockets/asset pipeline
!

Great theory, but very finicky in practice due to lots of moving
parts and last minute changes throughout 3.1 RC lifecycle
!
config.action_controller.perform_caching
= true
!

Laundry list
!

Stack traces incredibly deep
(
puts caller
or Sprockets barf)
!

Nice new router syntax
!

Nested form handling improvements
!
respond_with

is great or terrible based on who you ask

13
OpenLogic, Inc.
Sass
!

What CSS3 should have been






!

“Sass is
freakin
’ awesome”
!

“Never want to work without it again”
!

Couldn’t get Compass happy with Sprockets
!

Compass:
@include border-radius(4px)
!

Will try again now that Rails 3.1 & Sprockets 2.0 are final

14
li {
font: {
family: serif;
weight: bold;
size: 1.2em;
}
}
$blue: #3bbfce;
$margin: 16px;

.content-navigation {
border-color: $blue;
color: darken($blue, 9%);
}
OpenLogic, Inc.
Prototype vs.
jQuery

!

Prototype in production 4+ years
!
jQuery
starting slipping in early on
!

Using both in production for 3+ years
!

Strong preference for
jQuery
today
!

Has become a standard on the web
!

Practically every new JavaScript library is based on
jQuery

!

Default in Rails 3.1 makes it even better
!

UJS seems a little odd sometimes, although good for code
separation – “the Rails way”
15
OpenLogic, Inc.
!

Translates (compiles) to 100% pure JavaScript
!

Weird syntax, especially the whitespace-sensitive formatting
for a non-Python team
!

Inconsistent usage – still some JavaScript running around
!

Some
devs
don’t see the benefit
!

“just a new syntax” vs. “fixes JavaScript warts”
!

Might like it more when we have a more complex UI
16
number = 42
opposite = true
number = -42 if opposite
square = (x) -> x * x

list = [1, 2, 3, 4, 5]
math =
root:
Math.sqrt

square: square
cube: (x) -> x * square x
race = (winner, runners...) ->
print winner, runners

alert "I knew it!" if
elvis
?

cubes = (
math.cube

num
for
num
in list)
OpenLogic, Inc.
!

Client side JavaScript MVC support
!

Haven’t really needed the complexity yet
!

Too much to bite off with tight deadlines and no strong
requirement to use it
!

Happy with
CoffeeScript
, JavaScript, and
jQuery
for now
17
OpenLogic, Inc.
CouchDB
!

Great stability, cloud-safe
!

Affects everything
!

Every
datastore
-related tool understands SQL and/or
ActiveRecord
(e.g., Devise)
!

Restricts our choices to
CouchRest
Model aware code
!

Lots of
googling
for blogs, docs, experience
!

Growing pains – not a relational database
!

Modeling takes some experimenting and learning from mistakes
!

Views/queries are a paradigm shift
!

Mandatory optimistic locking implementation is a huge change
!

Prepare to handle 409’s
!

Used to MySQL - Redis was a no-brainer, CouchDB takes effort
18
OpenLogic, Inc.
CouchDB (cont.)
!
BigCouch

!

Clustered CouchDB
!

Dynamo concepts: read & write quorums,
replication
!

Great features, just what we need
!

More work and expense than we wanted
to bite off initially
!
Cloudant

!

Hosted
BigCouch
from its creators
!

Performance and reliability issues
!

Think in documents, not rows
!

Minimize round trips
!

Implement caching
19
OpenLogic, Inc.
Other key components
!

Devise
!

Authentication & sign up
!

Documentation not perfect
!

Takes some work to integrate with CouchDB
!

Machinist
!

Better fixtures, we moved from
factory_girl

!

Close, but not perfect replacement for “real” testing
!

Capybara &
WebDriver

!

In-browser JavaScript testing
!

Some impedance mismatch between simulated & real browsers
!

All changing, none perfect, require work
20
OpenLogic, Inc.
EC2 & Rackspace
!

Good
!

“Incredibly nice to fire up a new server, start from a clean slate”
!

Easy to throw development code into a production environment
!

“A better VMware than VMware”
!

Disposable snapshots
!

Bad
!

EC2 fragmentation is really annoying
!

Region-specific images, load balancer AZ issues
!

Ugly
!

API calls hang, VM’s won’t start, strange error conditions
!

Random slowness, inconsistencies abound
21
OpenLogic, Inc.
Final Thoughts
!

Business as usual for a new product release
!

Tight deadline, lots of pressure, many moving parts
!

All coming together at the last minute
!

Cloud services can help
!
Cloudant
(CouchDB hosting)
!
SimpleWorker
(async job management)
!
Dyn
(distributed DNS)
!

Wouldn’t work without
open source
!

Rails, Sass,
jQuery
, CouchDB,
CouchRest
Model,
BigCouch
,
Fog, Nginx, Unicorn, Devise, …
22
OpenLogic, Inc.
Q & A
Any questions for Rod?
rod.cope@openlogic.com
Slides:
http://www.openlogic.com/downloads/presentations.php

* Unless otherwise credited, all images in this presentation are either open source project logos or were licensed from BigStockPhoto.com