# Beyond Basecamp [Enrique García Cota](http://kiki.to) ([@otikik](http://twitter.com/otikik)) [Barcelona on Rails](http://www.meetup.com/Barcelona-on-Rails/) - Nov 2014
3Scale logo
#### [kikito.github.io/beyond-basecamp](https://kikito.github.io/beyond-basecamp)
# Intro
rails logo
> I have opinions
basecamp logo
basecamp
basecamp
# The Rails Way
basecamp
basecamp
## Basecampy Apps * One relational database + ActiveRecord * Light on the client-side * Conventions (helpers, erb, turbolinks, ...)
mad-max
# Small deviations
## [PostgreSQL](http://www.postgresql.org/)
> Relational Databases FTW
``` bash $ rails new myapp --database=postgresql ```
``` ruby # Gemfile gem 'sqlite3' ```
``` ruby # Gemfile gem 'pg' ```
## [CoffeeScript](http://coffeescript.org)
> CoffeeScript is better than Javascript
```ruby # Gemfile gem "coffee-rails" ```
```ruby # Gemfile # gem "coffee-rails" ```
```bash $ mv myapp.coffee myapp.js ```
```bash # Gemfile # gem "coffee-rails" ... gem "turbolinks"# -> coffee-rails ```
## [RSpec](http://rspec.info/)
> I consider rspec to have the worst DSL of any major piece of Ruby software.
```ruby # Gemfile group :development, :test do gem 'rspec-rails', '~> 3.0.0' end ```
```bash rails generate rspec:install ```
```bash $ git clone github.com/rspec/rspec-rails $ cloc rspec-rails ```
### ☞ ~120 ruby files, ~4600 LOC
Graph 1
Graph 2
Graph 3
Graph 4
# Real-life example
APITools Logo
APITools Schema
APITools Schema
### api.myapp.com/foo #⇩ ### myapp.apitools.com/foo
APITools Schema
APITools Schema
APITools Screenshot
# Speed
Nginx redis lua
* Overhead order: ~20ms * Roundtrip to our servers (worst case): 1s * Opensource self-hosted version available
APITools Logo

github.com/apitools/monitor

# Security
docker
1 nginx + 1 redis in 1 docker container = ## ~ 6MB
## APItools monitor
# ✘ ## Lots of DIY ## Very Bleeding Edge
# ✓ ## Fast, Safe ## Fun
brainslug
brainslug
# Multi-tenancy
## Provisioning API #### Divided into 3 parts:
### Restful API Server #### Built with Sinatra & Redis ``` bash $ curl http:://nixonserver.com/status => { "redis_connection" : true } ```
### CLI client #### Built with Thor ``` bash $ nixon assign af8bae 4 => Assigned container af8bae to account 4 ```
### Ruby client gem ```ruby # Gemfile source 'https://usr:pwd@geminabox.net' ... gem 'nixon-client' ... # Some controller / service nixon.accounts.put_to_sleep(slug_name) ```
# ✘ ## Triple work ## Naming
# ✓ ## Versatile
## Rails APP * MySQL database * Login access point * Contains account info * Connected with nixon via `nixon-client` * Hosts backups
brain screenshot
brain code screenshot
# ✘ ## Many Classes ## Naming
# ✓ ## Small Classes ## Easy to test
# Routing
### api.myapp.com/foo #⇩ ### myapp.apitools.com/foo
Nginx redis lua
# ✘ ## A bit DIY
# ✓ ## Small ## Zero-downtime deployment
![dwight](./img/dwight.jpg) [github.com/3scale/dwight-conrad](https://github.com/3scale/dwight-conrad)
# All together
Schema
          -------------------------
                    files      code
          -------------------------
          Ruby       599      16413
          Lua        147      10772
          Coffee      73       4380
          YAML        35       4263
          SASS        81       4206
          HTML        65       2581
          -------------------------
          SUM:      1000      42615
          -------------------------
          
# ✘ ## Complex ## DIY ## Naming
# ✓ ## Played to our strenghts ## Fun ## Works
## Conclusion
Graph 2
terminator
terminator
c-3po
r2d2
kitt
shopify article

www.shopify.com/technology/15646068

## Questions? --- [Enrique García Cota](http://kiki.to) ([@otikik](http://twitter.com/otikik))

Thank you!

bender