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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yasutomo Uemori
PRO
September 24, 2019
Programming
70
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
Transcript
13 slides
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を呼ぶことでいろいろ面白いことが出来るので、 活用する機会があれば試していきたい
ご静聴ありがとうございました
More Decks by Yasutomo Uemori
See All by Yasutomo Uemori
よくわかる新収益認識基準
wakaba260
PRO
0
1.7k
いまどきのゲームサーバアーキテクチャ
wakaba260
PRO
1
810
オンラインゲームのRails複数db戦略
wakaba260
PRO
0
100
Ruby/Rails Benchmarking and Profiling with TDD
wakaba260
PRO
0
99
GCP・GKEで作るスケーラブルなゲーム開発環境
wakaba260
PRO
0
97
サービスクラス、その前に
wakaba260
PRO
0
60
Rails on Dockerとの戦い
wakaba260
PRO
0
56
Rubocopとの付き合い方
wakaba260
PRO
0
68
Rails api way in aiming
wakaba260
PRO
0
71
Other Decks in Programming
See All in Programming
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
0
120
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
4
4.3k
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
190
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
860
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
370
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
130
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
230
SODA - FACT BOOK(JP)
sodainc
1
40k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
300
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
小さなアプリを作って公開するまで
onozaty
0
170
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
530
The browser strikes back
jonoalderson
0
1.9k
BBQ
matthewcrist
90
10k
Building Applications with DynamoDB
mza
96
7.3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
660
Done Done
chrislema
187
17k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
Balancing Empowerment & Direction
lara
6
1.4k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Between Models and Reality
mayunak
4
580
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
530