Skip to content

ELBのEC2のOut of Serviceへの移行について調査

mechamogera edited this page Sep 12, 2012 · 19 revisions

実験1

前準備

  • EC2インスタンス1準備(Amazon Linux)
  • httpd導入
$ sudo yum install -y httpd
  • httpdファイル配置
$ echo a | sudo tee /var/www/html/index.html
$ sudo touch /var/www/html/ping
  • httpd起動
$ sudo /etc/init.d/httpd start
  • EC2インスタンス2準備(Amazon Linux)
  • EC2インスタンス1と同様に準備
  • ただし、httpdファイルは以下のように配置
$ echo a | sudo tee /var/www/html/index.html
$ sudo touch /var/www/html/ping

実験手順

  • クライアントから以下のrubyスクリプトを実施
require 'rest-client'

while true
  begin
    res = RestClient.get( 'http://testELB-181078839.ap-northeast-1.elb.amazonaws.com/index.html' )
    puts res.body
  rescue => e
    p e.message
  end
end
  • EC2インスタンス1でhttpdを停止
$ sudo /etc/init.d/httpd stop

実験結果

  • クライアントの出力が以下のようになった
a
b
a
b
a
b
"Server broke connection"
b
"Server broke connection"
b
"Server broke connection"
b
b
b
b
b
b
b
Clone this wiki locally