Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <ilya@igvita.com>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
# required for passenger since cron has no environment
ENV['HTTPD'] = 'httpd'
MEM_LIMIT = ARGV[0] || 500
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
require 'logger'
class Logger
class Formatter
private
def msg2str(msg)
case msg
when ::String
"msg (pid: #{$$})"
when ::Exception
@deepak
deepak / log_pid.rb
Created June 25, 2010 06:55
logging the pid also so that the logs can be collected while doing distributed logging eg. passenger/mongrel
# source: http://gist.github.com/452539
# thanks to EP on
# http://groups.google.com/group/phusion-passenger/
# browse_thread/thread/a3221e0e15adc1ec
# [logger per spawner]
# add it to config/initializer in rails
# tested with rails-2.3.5
# simply giving the pid in the config will not work as it will be the
#!/usr/bin/env ruby
# NOTE: does not make sense to measure for large iterations, only as
# much as the logging being done on rails request, it is not as if on
# on a request 10K logging is done. With 50 logging statements i would
# prefer syslog
# NOTE: Also in buffered and syslog the
# log can get lost but logger is more reliable
# TODO: measure IO perf, if syslog logs on remote the io cost will be
#!/usr/bin/env ruby
# NOTE: does not make sense to measure for large iterations, only as
# much as the logging being done on rails request, it is not as if on
# on a request 10K logging is done. With 50 logging statements i would
# prefer syslog
# NOTE: Also in buffered and syslog the
# log can get lost but logger is more reliable
# TODO: measure IO perf, if syslog logs on remote the io cost will be
@deepak
deepak / logging.rb
Created July 6, 2010 08:47
benchmarking logging in ruby using syslog and bufferredlogger
#!/usr/bin/env ruby
# NOTE: does not make sense to measure for large iterations, only as
# much as the logging being done on rails request, it is not as if on
# on a request 10K logging is done. With 50 logging statements i would
# prefer syslog
# NOTE: Also in buffered and syslog the
# log can get lost but logger is more reliable
# TODO: measure IO perf, if syslog logs on remote the io cost will be
@deepak
deepak / .reerc
Created July 6, 2010 08:48
various REE gc settings
# source: http://github.com/rtomayko/dotfiles/blob/rtomayko/.reerc
# baseline REE environment settings for server environments
# http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning
## ruby defaults
# RUBY_HEAP_MIN_SLOTS=10000
# RUBY_HEAP_SLOTS_INCREMENT=10000
# RUBY_HEAP_SLOTS_GROWTH_FACTOR=1.8
# RUBY_GC_MALLOC_LIMIT=8000000