Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Active job meets kubernetes
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yasutomo Uemori
PRO
September 24, 2019
Programming
0
38
Active job meets kubernetes
Kubernetes Meetup Osaka #1でのLT資料です
Yasutomo Uemori
PRO
September 24, 2019
Tweet
Share
More Decks by Yasutomo Uemori
See All by Yasutomo Uemori
よくわかる新収益認識基準
wakaba260
PRO
0
900
いまどきのゲームサーバアーキテクチャ
wakaba260
PRO
1
440
オンラインゲームのRails複数db戦略
wakaba260
PRO
0
80
Ruby/Rails Benchmarking and Profiling with TDD
wakaba260
PRO
0
61
GCP・GKEで作るスケーラブルなゲーム開発環境
wakaba260
PRO
0
74
サービスクラス、その前に
wakaba260
PRO
0
38
Rails on Dockerとの戦い
wakaba260
PRO
0
37
Rubocopとの付き合い方
wakaba260
PRO
0
41
Rails api way in aiming
wakaba260
PRO
0
42
Other Decks in Programming
See All in Programming
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
330
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
520
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
350
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
350
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1k
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
470
CSC307 Lecture 15
javiergs
PRO
0
220
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
120
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
2
420
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
920
受け入れテスト駆動開発(ATDD)×AI駆動開発 AI時代のATDDの取り組み方を考える
kztakasaki
2
520
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
390
Featured
See All Featured
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
200
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
How STYLIGHT went responsive
nonsquared
100
6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
220
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
99
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
470
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
GraphQLの誤解/rethinking-graphql
sonatard
75
11k
Between Models and Reality
mayunak
2
230
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
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を呼ぶことでいろいろ面白いことが出来るので、 活用する機会があれば試していきたい
ご静聴ありがとうございました