unicorn-worker-killer 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,12 @@
1
- Release 0.1 - 2012/11/17
1
+ Release 0.2.0 - 2012/11/22
2
+
3
+ * Change namespace to Unicorn::WorkerKiller from UnicornWorkerKiller
4
+
5
+ Release 0.1.2 - 2012/11/17
6
+
7
+ * Change unicorn version dependency to '~> 4'
8
+
9
+ Release 0.1.1 - 2012/11/17
2
10
 
3
11
  * Fix homepage
4
12
 
data/README.md CHANGED
@@ -1,23 +1,43 @@
1
1
  # unicorn-worker-killer
2
2
 
3
- Killing Unicorn worker based on 1) Max number of requests and 2) Process memory size (RSS), without affecting the request.
3
+ [Unicorn](http://unicorn.bogomips.org/) is widely used HTTP-server for Rack applications. One thing we thought Unicorn misssed, is killing the Unicorn workers based on the number of requests and consumed memories.
4
+
5
+ `unicorn-worker-killer` gem provides automatic restart of Unicorn workers based on 1) max number of requests, and 2) process memory size (RSS), without affecting any requests. This will greatly improves site's stability by avoiding unexpected memory exhaustion at the application nodes.
4
6
 
5
7
  # Install
6
8
 
9
+ No external process like `god` is required. Just install one gem: `unicorn-worker-killer`.
10
+
7
11
  gem 'unicorn-worker-killer'
8
12
 
9
13
  # Usage
10
14
 
11
- Add these lines to your `config.ru`. It's highly recommended to randomize these numbers, to avoid killing all workers at once.
15
+ Add these lines to your `config.ru`.
12
16
 
13
17
  # Unicorn self-process killer
14
18
  require 'unicorn/worker_killer'
15
19
 
16
20
  # Max requests per worker
17
- use UnicornWorkerKiller::MaxRequests, 10240 + Random.rand(10240)
21
+ use Unicorn::WorkerKiller::MaxRequests, 10240 + Random.rand(10240)
18
22
 
19
23
  # Max memory size (RSS) per worker
20
- use UnicornWorkerKiller::Oom, (96 + Random.rand(32)) * 1024**2
24
+ use Unicorn::WorkerKiller::Oom, (96 + Random.rand(32)) * 1024**2
25
+
26
+ This gem provides two modules.
27
+
28
+ ### Unicorn::WorkerKiller::MaxRequests(max_requests = 1024)
29
+
30
+ This module automatically restarts the Unicorn workers, based on the number of requests which worker processed.
31
+
32
+ `max_requests` specifies the maximum number of requests which this worker should process. Once the number exceeds `max_requests`, that worker is automatically restarted. It's highly recommended to randomize this number to avoid restarting all workers at once.
33
+
34
+ ### Unicorn::WorkerKiller::Oom(memory_size = (1024**3), check_cycle = 16)
35
+
36
+ This module automatically restarts the Unicorn workers, based on its memory size.
37
+
38
+ `memory_size` specifies the maximum memory which this worker can have. Once the memory size exceeds `memory_size`, that worker is automatically restarted. It's highly recommended to randomize this number to avoid restarting all workers at once.
39
+
40
+ The memory size check is done in every `check_cycle` requests.
21
41
 
22
42
  # TODO
23
43
  - Get RSS (Resident Set Size) without forking the child process at Mac OS and Windows
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -1,4 +1,4 @@
1
- module UnicornWorkerKiller
1
+ module Unicorn::WorkerKiller
2
2
  # Self-destruction by sending the signals to myself. The process sometimes
3
3
  # doesn't terminate by SIGTERM, so this tries to send SIGQUIT and SIGKILL
4
4
  # if it doesn't finish immediately.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn-worker-killer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-18 00:00:00.000000000 Z
13
+ date: 2012-11-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: unicorn