Slide 1

Slide 1 text

! From ‘Legacy' to ‘Edge' 2014 edition ! Hiroshi SHIBATA @hsbt OedoRubyKaigi04

Slide 2

Slide 2 text

SHIBATA Hiroshi(@hsbt)

Slide 3

Slide 3 text

asakusa.rb

Slide 4

Slide 4 text

ruby-lang.org

Slide 5

Slide 5 text

Rails Girls in Japan

Slide 6

Slide 6 text

Ruby Committer

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

ϛυϧ΢ΣΞͷΞοϓάϨʔυ ࣾ಺։ൃج൫ͷߏங ౷ܭج൫ͷߏங +409ͷӡ༻੔උ HJUIVC ηΩϡϦςΟ؂ࠪ ίʔυϨϏϡʔ ςετج൫ͷߏங ΞΫηεղੳج൫ͷߏங ։ൃϓϩηε ৽ਓڭҭ ݪߘࣥච ΧϯϑΝϨϯεൃද 044։ൃ αʔόʔߏ੒؅ཧͷ࡮৽ ϦʔϯελʔτΞοϓ +FOLJOT 3VCZ3BJMT 3%#.4 ٕज़ج൫νʔϜ

Slide 9

Slide 9 text

http://30d.jp

Slide 10

Slide 10 text

from 2007/5

Slide 11

Slide 11 text

380,000 users 230,000,000 photos

Slide 12

Slide 12 text

Our Rails app 46 models 5000 lines in controllers 400 lines in routes.rb 1:1.3 code to test ratio

Slide 13

Slide 13 text

system architecture

Slide 14

Slide 14 text

application server

Slide 15

Slide 15 text

storage server

Slide 16

Slide 16 text

job server

Slide 17

Slide 17 text

transaction server

Slide 18

Slide 18 text

storage is over 450 TB

Slide 19

Slide 19 text

database size is over 250 GB

Slide 20

Slide 20 text

Development Culture

Slide 21

Slide 21 text

จࣈ github workflow

Slide 22

Slide 22 text

IRC github issue costomer’s contact nagios

Slide 23

Slide 23 text

DevOps

Slide 24

Slide 24 text

4 deploy/day

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

How to migrate edge rails from legacy rails?

Slide 27

Slide 27 text

Ruby 1.8.6 Rails 2.0.2

Slide 28

Slide 28 text

Ruby 1.8.6 Rails 2.0.2 Ruby 2.1.1 Rails 4.1.0 new!

Slide 29

Slide 29 text

Why?

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Ruby on Rails

Slide 32

Slide 32 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 33

Slide 33 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0 Slow Fast

Slide 34

Slide 34 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 35

Slide 35 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 36

Slide 36 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 37

Slide 37 text

Rails 2.0 Rails 2.3

Slide 38

Slide 38 text

Rails 2.0 Rails 2.3 hotfix A migration A

Slide 39

Slide 39 text

Rails 2.0 Rails 2.3 hotfix A migration A

Slide 40

Slide 40 text

Rails 2.0 Rails 2.3 hotfix A migration A

Slide 41

Slide 41 text

จࣈ

Slide 42

Slide 42 text

Zero Downtime Deploy

Slide 43

Slide 43 text

cookpad/kage

Slide 44

Slide 44 text

Kage (kah-geh) is an HTTP shadow proxy server that sits between clients and your server(s) to enable "shadow requests".

Slide 45

Slide 45 text

the basic of kage real request

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

_ਓਓ ਓਓ__ਓਓ ਓਓ_! > ಥવͷαʔόʔ࠶ىಈ

Slide 48

Slide 48 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 49

Slide 49 text

rails 2.3 with bundler

Slide 50

Slide 50 text

source 'https://rubygems.org'! ! gem 'rails', '~> 2.3.18'! gem 'rake', '~> 0.9.2'! gem 'rdoc'! gem 'rake-confirm'! ! gem 'mysql'! gem "mysql_retry_lost_connection"! gem 'acts_as_paranoid', :github => 'paperboy-30days/acts_as_paranoid'! gem 'passenger', '~> 3.0'! gem 'memcache-client', :require => 'memcache'! gem 'system_timer'! gem 'yajl-ruby', :require => 'yajl'! gem 'will_paginate', '~> 2.3'! gem 'mail'! ! gem 'sass'! gem 'compass-rails'! ! gem 'osaipo_client', :git => '[email protected]:paperboy-all/ osaipo_client.git', :branch => 'legacy'! gem 'jugem_client', :git => '[email protected]:paperboy-all/ jugem_client.git'! gem 'ppb_footer', :github => 'paperboy-all/ppb_footer'!

Slide 51

Slide 51 text

require "./config/environment"! ! use Rails::Rack::LogTailer! use Rails::Rack::Static! run ActionController::Dispatcher.new rack with rails 2.3

Slide 52

Slide 52 text

30days-front can’t use hyphen can’t use number can’t convert ! application.rb...

Slide 53

Slide 53 text

Reduce customer frustration.

Slide 54

Slide 54 text

app1 app2 backgroundrb to dj

Slide 55

Slide 55 text

จࣈ

Slide 56

Slide 56 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 57

Slide 57 text

Use trunk everyday.

Slide 58

Slide 58 text

จࣈ

Slide 59

Slide 59 text

จࣈ

Slide 60

Slide 60 text

Use modern architecture

Slide 61

Slide 61 text

app1 app2

Slide 62

Slide 62 text

kyoto tycoon is slower than mysql…

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

1.8 to 2.0

Slide 65

Slide 65 text

จࣈ

Slide 66

Slide 66 text

2.0 to 2.1

Slide 67

Slide 67 text

CPU Usage(%) 0 25 50 75 100 49 69 2.0 2.1

Slide 68

Slide 68 text

Resp. time(ms) 0 50 100 150 200 250 189 221 2.0 2.1

Slide 69

Slide 69 text

memory usage(giga byte) 0 1 2 3 4 3.8 3.2 2.0 2.1

Slide 70

Slide 70 text

จࣈ https://www.ruby-lang.org/en/news/2014/03/10/regression-of-hash-reject-in-ruby-2-1-1/

Slide 71

Slide 71 text

Ruby 1.8.6 1.8.7 1.9.3 2.0.0 2.1 Rails 2.0/2.1 2.3 3.0 3.2 4.0

Slide 72

Slide 72 text

จࣈ

Slide 73

Slide 73 text

Resp. time(ms) 0 60 120 180 240 300 287 189 3.2 4.0

Slide 74

Slide 74 text

Ruby 1.9.3 2.0.0 2.1 2.2 Rails 3.0 3.2 ? 4.0 ? 4.1 ?

Slide 75

Slide 75 text

Ruby 1.9.3 2.0.0 2.1 2.2 Rails 3.0 3.2 ? 4.0 ? 4.1 ? New!!

Slide 76

Slide 76 text

จࣈ

Slide 77

Slide 77 text

1. Flash structure changes 2. Mutator methods called on Relation

Slide 78

Slide 78 text

จࣈ

Slide 79

Slide 79 text

Resp. time(ms) 0 60 120 180 240 300 266 287 4.0 4.1

Slide 80

Slide 80 text

Ruby 1.9.3 2.0.0 2.1 2.2 Rails 3.0 3.2 ? 4.0 ? 4.1 ?

Slide 81

Slide 81 text

class Bar! def bar(foo = foo())! foo! end! ! def buzz(foo = foo)! foo! end! ! def foo! :buzz! end! end! ! p Bar.new.bar! p Bar.new.buzz

Slide 82

Slide 82 text

% ruby -v r45272.rb! ruby 2.2.0dev (2014-04-13 trunk 45580) [x86_64-darwin13]! :buzz! nil! ! % ruby -v r45272.rb! ruby 2.1.2p80 (2014-03-01 revision 45231) [x86_64-darwin13.0]! :buzz! :buzz

Slide 83

Slide 83 text

จࣈ

Slide 84

Slide 84 text

conclusion

Slide 85

Slide 85 text

2. fix gem 4. fix Ruby 3. fix Rails 1. fix your code