SlideShare a Scribd company logo
Ruby Daemons
Creston Jamison
RubyTree Software, Inc.
Ruby Daemons
GAMEhud
 HTTPAPI accepts event and player based
data from game clients.
 Incoming data needs to be distributed
between 10-20 tables.
 Don’t want to do that in the request.
 Need to do background processing!
1. Reliability
2. Speed
Background Processing Options
 Delayed Job
 Beanstalkd
 Resque
 Sidekiq
 Queue Classic
 Daemons
Delayed Job
 Uses rake
 Uses full rails environment
 Best for long running and infrequent jobs
Beanstalkd
 Fast queue
 Does not poll
 Good for raw speed
 Authentication and queue management ?
Resque
 Redis based queue system
 Requires Redis
 Comes with an admin interface
 Uses polling
Sidekiq
 Redis based queue system
 Requires Redis
 Comes with an admin interface
 Uses polling
 Uses threads
 Code needs to be thread safe
Queue Classic
 Postgres based queue system
 Requires postgresql
 Avoids separate queue process
 Can avoid polling
Queue vs. Worker
Daemons
 Converts a script into a daemon
 Not a queue system
 A way to create a worker process
What is a daemon?
 A computer program that runs as a
background process
 Daemon processes typically end in ‘d’
 For example: sshd
Setting up a daemon
 Install daemons gem
 Create a control file
event_worker_control.rb
 Create a loop in the script called by the control file
event_worker.rb
Create a control file
require 'rubygems'
require 'bundler/setup'
require 'daemons'
Daemons.run('lib/daemons/event_worker.rb')
Loop in your script
$: << File.expand_path(".", File.dirname(__FILE__))
require ‘event_processor'
event_processor = EventProcessor.new
loop do
event_processor.process
sleep(5)
end
Control your daemon
 ruby daemon-name_control.rb start
 ruby daemon-name_control.rb restart
 ruby daemon-name_control.rb stop
 ruby lib/daemons/event_worker_control.rb
start -- production
 PID file
Capistrano
before 'deploy:update_code', 'deploy:stop_workers'
desc "Stop the worker processes“
task :stop_workers, :roles => :app do
run "cd #{current_path};
ruby lib/daemons/event_worker_control.rb
stop -- production“
end
Gotchas
 Need rock solid error handling
 Otherwise your process dies
 Need a way to skip over errors and come back
to them
Extra Credit
jstorimer.com/2012/04/19/daemon-processes-in-ruby.html
labs.headlondon.com/2010/07/skinny-daemons/
Questions?
Creston Jamison
@crestonjamison
creston.jamison@rubytreesoftware.com

More Related Content

ODP
Choosing a Web Architecture for Perl
PDF
Donatas Mažionis, Building low latency web APIs
PDF
High Performance Python Microservice Communication
PPTX
Ruby and Framework Security
PDF
Petit DéJeuner Industrialisation 13 10 2011 Eurosites
PPT
Retour d'expérience sur Capistrano
PPTX
Capistrano 3 Deployment
PPTX
Happy birthday "monUPMC": 9 years of Portal at UPMC
Choosing a Web Architecture for Perl
Donatas Mažionis, Building low latency web APIs
High Performance Python Microservice Communication
Ruby and Framework Security
Petit DéJeuner Industrialisation 13 10 2011 Eurosites
Retour d'expérience sur Capistrano
Capistrano 3 Deployment
Happy birthday "monUPMC": 9 years of Portal at UPMC

Viewers also liked (9)

PDF
Retour d'expérience : Mise en place de l'ENT v4 à l'UPMC
PDF
Deploiement continu AgileFfrance 2011
PPTX
GitHub - Présentation
PDF
Découvrir et utiliser Git : le logiciel de gestion de versions décentralisé
PDF
Git pour les (pas si) nuls
ODP
Industrialisez vos projets Php
PDF
2015 Upload Campaigns Calendar - SlideShare
PPTX
What to Upload to SlideShare
PDF
Getting Started With SlideShare
Retour d'expérience : Mise en place de l'ENT v4 à l'UPMC
Deploiement continu AgileFfrance 2011
GitHub - Présentation
Découvrir et utiliser Git : le logiciel de gestion de versions décentralisé
Git pour les (pas si) nuls
Industrialisez vos projets Php
2015 Upload Campaigns Calendar - SlideShare
What to Upload to SlideShare
Getting Started With SlideShare
Ad

Similar to Ruby Daemons (20)

PPT
Red Hat Enterprise Linux 7
PPTX
Scaling asp.net websites to millions of users
PPT
WE18_Performance_Up.ppt
PPT
5 Years of Progress in Active Data Warehousing
PDF
Making it fast: Zotonic & Performance
PPTX
Game server development in node.js in jsconf eu
PDF
Http2 in practice
PDF
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
PPT
Ch 22: Web Hosting and Internet Servers
PDF
Making the web faster
PPTX
(Don't) Go Tracing Server Calls
PDF
PPT
Managing and Monitoring TeamPage
PDF
Event Driven Architecture Concepts in Web Technologies - Part 2
PDF
Node.js
PPTX
Minor Project (Gagan Bhalla)
PPTX
Debugging the Web with Fiddler
PPTX
Sticky Keys to the Kingdom
PDF
AD102 - Break out of the Box
PPT
System Security
Red Hat Enterprise Linux 7
Scaling asp.net websites to millions of users
WE18_Performance_Up.ppt
5 Years of Progress in Active Data Warehousing
Making it fast: Zotonic & Performance
Game server development in node.js in jsconf eu
Http2 in practice
InSecure Remote Operations - NullCon 2023 by Yossi Sassi
Ch 22: Web Hosting and Internet Servers
Making the web faster
(Don't) Go Tracing Server Calls
Managing and Monitoring TeamPage
Event Driven Architecture Concepts in Web Technologies - Part 2
Node.js
Minor Project (Gagan Bhalla)
Debugging the Web with Fiddler
Sticky Keys to the Kingdom
AD102 - Break out of the Box
System Security
Ad

Recently uploaded (20)

PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administraation Chapter 3
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
assetexplorer- product-overview - presentation
PPTX
Transform Your Business with a Software ERP System
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
ai tools demonstartion for schools and inter college
PPTX
history of c programming in notes for students .pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo Companies in India – Driving Business Transformation.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Design an Analysis of Algorithms II-SECS-1021-03
CHAPTER 2 - PM Management and IT Context
Digital Systems & Binary Numbers (comprehensive )
Design an Analysis of Algorithms I-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administraation Chapter 3
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
assetexplorer- product-overview - presentation
Transform Your Business with a Software ERP System
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Adobe Illustrator 28.6 Crack My Vision of Vector Design
ai tools demonstartion for schools and inter college
history of c programming in notes for students .pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf

Ruby Daemons