Skip to content

Instantly share code, notes, and snippets.

View krasio's full-sized avatar
🎣
Gone fishing

Krasimir Angelov krasio

🎣
Gone fishing
View GitHub Profile
@krasio
krasio / passenger_process.rb
Created December 2, 2011 14:31 — forked from leejones/passenger_process.rb
Remove orphaned passenger processes.
require 'chronic'
class PassengerProcess
attr_accessor :pid, :uptime
def initialize(passenger_status_line)
values = passenger_status_line.match(/PID:\s(\d*).*Uptime:\s*(.*)$/)
@pid = values[1].to_i
@uptime = values[2]
end
@krasio
krasio / new-vm.textile
Created December 14, 2011 14:03 — forked from petyosi/new-vm.textile
Instructions on setting up new work VM.

Installation

  • Update your VirtualBox
  • Download ubuntu LTS server (64 bit)
  • name “garmz-dev”
  • Run default installation from the downloaded iso in new VM
    • hostname “garmz-dev”
    • Don’t encrypt home
    • No automatic updates
    • Pick OpenSSH server and PostgreSQL server
@krasio
krasio / excon benchmark
Created December 15, 2011 14:23 — forked from phiggins/excon benchmark
excon benchmark vs google
$ ruby benchmarks/excon_vs_google.rb
[em-http-request, HTTParty, Net::HTTP, Net::HTTP (persistent), open-uri, RestClient, StreamlyFFI (persistent), Typhoeus, Excon, Excon (persistent)]
+--------------------------+-----------+
| tach | total |
+--------------------------+-----------+
| Excon | 7.614298 |
+--------------------------+-----------+
| Typhoeus | 7.723362 |
@krasio
krasio / new-vm.textile
Created December 29, 2011 19:25 — forked from petyosi/new-vm.textile
Instructions on setting up new work VM.

Installation

  • Update your VirtualBox
  • Download ubuntu LTS server (64 bit)
  • name “garmz-dev”
  • Run default installation from the downloaded iso in new VM
    • hostname “garmz-dev”
    • Don’t encrypt home
    • No automatic updates
    • Pick OpenSSH server and PostgreSQL server
@krasio
krasio / gist:1560639
Created January 4, 2012 15:51 — forked from tjl2/gist:1330498
Changing the count and memory limit of Passenger processes on Engine Yard Cloud

This was going to go into a blog post, but was removed after discussion around it being a Bad Thing for customers to do.

Changing the count and memory limit of Passenger processes

To stop applications that are prone to bloating quickly exhausting all the memory on an application instance, we have a script called passenger_monitor that checks for runaway Passenger processes every minute via a cron job. By default, this script is going to look for Passenger workers that are using over 215MB of memory and kill them. Passenger will restart them when needed. We tune the number of workers that run by default on your application instances, based on the memory specifications so that the memory is sensibly utilized. However, if your application legitimately requires more memory than this (i.e. it isn’t bloating) then it may be advantageous for you to reduce the worker count, and allow the lower number of workers to use more memory.

Doing this involves two areas of customization; modifying the Nginx configuratio

@krasio
krasio / ruby_gc.sh
Created February 28, 2012 10:02 — forked from mikhailov/ruby_gc.sh
Ruby’s GC Configuration
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration
article’s settings: ("spec spec" took 17-23!sec)
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500
#!/usr/bin/env ruby
require 'socket'
test_file = ARGV[0]
socket = UNIXSocket.new('testing.sock')
socket.write(test_file)
socket.close_write
@krasio
krasio / poolboy_demo.ex
Created March 18, 2016 09:51 — forked from henrik/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000