SlideShare a Scribd company logo
1 of 24
Download to read offline
Heroku add-on
Bounscaleで
Play2/Scalaを
オートスケールする
Shota Onishi
13年10月21日月曜日
はじめに

13年10月21日月曜日
About this LT
• DTSでBounscaleというオートスケール
するHerokuのadd-onを作っています。
紹介させてください。

• Play2/Scalaに対応してます。(Experimental)
対応した時に得たトピックも少し紹介
します。

13年10月21日月曜日
About me
•
•
•
•
•
•

大西 正太 @shouta_dev
(株)DTS
2005年位からRailsやってます
ScalaもPlayも初心者です!
マイブームは重力
お酒が大好き!クズ居酒屋が大好き!吉田類
の酒場放浪記が大好き!

13年10月21日月曜日
Bounscaleの機能

13年10月21日月曜日
Heroku?
• いろいろ動くPaaS (Play/Scalaも)
• スライダずらすとスケールアウト
• Rubyの有名人が社員

13年10月21日月曜日
Bounscale?
Heroku上の
サービス運営者が

四六時中
手作業で
スケールアウト
をせずに

13年10月21日月曜日

突如の高負荷時に一定
のレスポンスタイムを
維持できる
Install
$ heroku addons:add bounscale

OR
https://addons.heroku.com/bounscale/

13年10月21日月曜日
Adding the agent to your app
# Rails (Rack)
gem ’bounscale’ #Gemfile

:Gem

# node.js/express:npm [EXPERIMENTAL]
”dependencies” : {”bounscale”, ”*”} // package.json
app.use(require(’bounscale’)); // app.js

# Play Framework2:sbt [EXPERIMENTAL]
/* Build.scala */
"bounscale" % "bounscale_2.10" % "0.0.1";
resolvers += "r" at "http://bounscale.github.io/maven/";
/* Global.scala */
import play.api.GlobalSettings
import play.api.mvc.WithFilters
import com.bounscale.BounscaleFilter
object Global extends WithFilters(
new BounscaleFilter) with GlobalSettings
more detail: https://devcenter.heroku.com/articles/bounscale
13年10月21日月曜日
Open dashboard

13年10月21日月曜日
Settings

13年10月21日月曜日
Auto-scaling config
•

レスポンスタイム+別指標値
で負荷を測定

•

•

ビジー率 / スループット / cpu / memory

グラフ上でスケールアウトの
閾値を指定

13年10月21日月曜日
Dyno History

13年10月21日月曜日
Bounscale Inside
(Play/Scala対応の話)

13年10月21日月曜日
トピック
(1)agentの実装
(2)ライブラリの公開
13年10月21日月曜日
Architecture
Bounscale Architecture

Application

Heroku

Service Appliction

User

Rack Server

Use this service

agent
bounscale
gem
(middleware)

Log

Heroku Logs

Resource
Data

Collect and Write
Resource Datas

Resource
Data

Heroku API
Rails/
Application

www.heroku.com
(heroku console)

Addon Provisioning
API
Resource
Data

Request Addon / Request SSO
Get Logs
(heroku logs)

Provisioning
Response

Zabbix Custom Items

ct

Apache

Update
Scale Config

Create tenant

Multitenant
UserA
UserA
Access Model
Tenant
Tenant Create

Web Console
tenant

Console
Controller

Zabbix Access
UserA
UserA
Model
Tenant
Tenant

Update Zabbix

Twitter
Bootstrap

Save Cache
Data

Get Cache
Data

Update&Create
Items, Triggers,
Actions

Resource
Data

MySQL

Get cache

UserA
CacheUserA
Model
Tenant
Tenant

Bizca Multitenant
Ruby on Rails

Tenant
Control

Tenant
database
Tenant
database
Tenant
zabbixdatabase
cache
data

Extract
resource
datas

Update/Get

Resource
Data

Scalein Action

shell scipt / Ruby

Trigger

Zabbix
(scale condition)

Zabbix Server
MySQL

Conditionally
Kick Actions

Zabbix database
Tenant1
zabbix history
data

Tenant2
zabbix history
data

Tenant3
zabbix history
data

Tenant1
zabbix config
data

Tenant2
zabbix config
data

Tenant3
zabbix config
data

CentOS

CentOS

AWS

13年10月21日月曜日

Scaleout
Action

shell scipt / Ruby

Return
Resource

Show Resource
Graph

Resource
Data

Throughput
Item

Periodically
Kick

Provision
Controller

CPU Item

Cache Collector

Zabbix API (Apache/PHP)

Provisioning

Web Item

Collect
History Data

Heroku Access
UserA
UserA
Model
Tenant
Tenant

Zabbix Custom Action

Busyness
Item

memory
Item

Save
Resource
Data

re
di

Heroku SSO

Scale in

AWS

Save
Scalein/out
hitories

Rack Server

re

Developer

Scale out

Get Item,
Trigger, Action

Provisioning Request
agent?
• agentとは
•

リクエストの事前・事後処理でメトリクス
情報を収集してログに書きだすライブラリ

•

CPU情報とか、スループットとか

• Zabbixでそのログを見てオートスケール
の判断をしている

• フレームワーク毎に作る必要性
13年10月21日月曜日
Rails => Rack Middleware
HTTP req

HTTP res

Rack Server (Unicorn/Passenger)
Rack Middleware
Framework(Rails)
Application

cpu
memory
throuput
Log

13年10月21日月曜日
Play! =>Filter
HTTP req

HTTP res

Web Server (Netty)
Filter (after Play 2.1.1)
Framework(Play!2)
Application

cpu
memory
throuput
Log

13年10月21日月曜日
Agent’s source code
class BounscaleFilter extends Filter {
def apply(next: (RequestHeader) => Result)(rh: RequestHeader) = {
val collectors = List(
new CpuCollector(),
new MemoryCollector(),
new BusynessCollector(),
new ThroughputCollector()
)
def post(result: PlainResult): Result = {
collectors.foreach(collector => collector.post())
val writer = new HerokuWriter()
writer.write(collectors)
result
}

<=post def

collectors.foreach(collector => collector.pre())

}

}

<=pre exe

next(rh) match {
case plain: PlainResult => post(plain)
case async: AsyncResult => async.transform(post)
}

<=post exe

https://github.com/bounscale/bounscale_play2/blob/master/src/main/scala/BounscaleFilter.scala
13年10月21日月曜日
Publishing agents
gem push
npm publish

Published
Published

Create JIRA Ticket
Ack (operator 2-3days?)
Upload library
Update JIRA Ticket
Ack (operator)

至れり尽くせりの重厚さ
13年10月21日月曜日

Published
Publish to Github pages
• 今回はGithub Pages使って野良Mavenリ
ポジトリを作って公開しました

• やり方公開してます
•
•

13年10月21日月曜日

Play2/Scala向けライブラリを公開する(SBTでGithub上のMavenに)
http://qiita.com/bounscale/items/44b1729db39edbb507fd
Try it out !!
$ heroku addons:add bounscale

現在Public Betaで利用は無料です!

13年10月21日月曜日
Resources
• https://devcenter.heroku.com/articles/
bounscale

• https://github.com/bounscale
• http://qiita.com/bounscale/
• https://twitter.com/bounscale/
13年10月21日月曜日

More Related Content

Recently uploaded

Recently uploaded (10)

LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Heroku add-on BounscaleでPlay2/Scalaをオートスケールする