Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Active job meets kubernetes
Search
Yasutomo Uemori
PRO
September 24, 2019
Programming
63
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Active job meets kubernetes
Kubernetes Meetup Osaka #1でのLT資料です
Yasutomo Uemori
PRO
September 24, 2019
More Decks by Yasutomo Uemori
See All by Yasutomo Uemori
よくわかる新収益認識基準
wakaba260
PRO
0
1.5k
いまどきのゲームサーバアーキテクチャ
wakaba260
PRO
1
630
オンラインゲームのRails複数db戦略
wakaba260
PRO
0
99
Ruby/Rails Benchmarking and Profiling with TDD
wakaba260
PRO
0
88
GCP・GKEで作るスケーラブルなゲーム開発環境
wakaba260
PRO
0
95
サービスクラス、その前に
wakaba260
PRO
0
54
Rails on Dockerとの戦い
wakaba260
PRO
0
53
Rubocopとの付き合い方
wakaba260
PRO
0
61
Rails api way in aiming
wakaba260
PRO
0
65
Other Decks in Programming
See All in Programming
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
210
Press start. Python's next generation.
willingc
PRO
3
330
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
910
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
120
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
150
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
130
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
280
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
130
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.7k
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
Optimizing for Happiness
mojombo
378
71k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
So, you think you're a good person
axbom
PRO
2
2.1k
Design in an AI World
tapps
1
310
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
Thoughts on Productivity
jonyablonski
76
5.4k
How to build a perfect <img>
jonoalderson
1
6k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Designing Experiences People Love
moore
143
24k
Transcript
ActiveJob meets Kubernetes Kubernetes Meetup Osaka #1 LT 植森 康友(wakaba260)
me.inspect => { “HN”: "wakaba260", “name”: "Yasutomo Uemori", “company”: "株式会社Aiming",
“twitter”: "https://twitter.com/wakaba260yen", “github”: "https://github.com/yuemori", “skills”: ["rails api", "docker", "kubernetes", "GCP"] }
ActiveJob?
ActiveJob(Rails) - Ruby on Railsの非同期ジョブの仕組み - Adapterを実装することでなんでもバックエンドに出来る - 現在の主な実装例 -
Sidekiq, Resque: ruby製のjob queue worker - Shoryuken: Amazon SQSをメッセージキューに使える
ActiveJobの使用例 class GuestsCleanupJob < ApplicationJob queue_as :default def perform(*args) #
後で実行したい作業をここに書く end end # 「キューイングシステムが空いたらジョブを実行する」とキューに登録する guest = Guest.find(guest_id) GuestsCleanupJob.perform_later(guest)
Rails on Kubernetesでのジョブの運用 - SidekiqのworkerをDeploymentで立てる - ジョブキューのBackendにredisを立てる - replicas指定でworker数を増やしてスケールアウト
唐突な思いつき - Sidekiqのworkerのスケールアウトを考えるとCPU使用率などでは 上手くスケールできない - Kubernetesには既にJobという仕組みがある - リトライ、タイムアウトなど機能も充実 - Kubernetes
Jobを使うことでいい感じにスケールできそう
作ってみた https://github.com/yuemori/kube_queue/
# app/jobs/print_message_job.rb class PrintMessageJob < ApplicationJob include KubeQueue::Worker worker_name 'print-message-job'
image "your-registry/your-image" container_name 'your-container-name' def perform(payload) logger.info payload[:message] end end PrintMessageJob.perform_later(message: ‘hello!’)
class ComputePiJob < ApplicationJob include KubeQueue::Worker worker_name 'pi' image 'perl'
container_name 'pi' command "perl","-Mbignum=bpi","-wle","print bpi(2000)" cpu_limit '0.3' cpu_request '0.2' memory_limit '100m' memory_request '50m' end
kube_queueの実装 - perform_laterを呼んだら指定されたJobを起動 - やってることはJob作成のAPIを呼ぶだけ
やってみてわかったこと - スケールアウトがworkerのreplica数からリソースに依存するように なった - KubernetesのAPI経由でコンテナを呼ぶことで、プラットフォームや 言語に依存せずにコンテナの恩恵を享受できる - KubernetesのAPIを呼ぶことでいろいろ面白いことが出来るので、 活用する機会があれば試していきたい
ご静聴ありがとうございました