Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 140 lines (94 sloc) 6.245 kB
888120e @noahd1 initial commit
authored
1 === Oink
2
3 * http://github.com/noahd1/oink
4
5 === Description
6
697d37e @noahd1 adding to documentation
authored
7 Rails plugin and log parser to help narrow down the source(s) of increased memory usage in rails applications.
888120e @noahd1 initial commit
authored
8
9 === Synopsis
10
697d37e @noahd1 adding to documentation
authored
11 Oink adds memory and active record instantiation information to rails log during runtime and provides an executable to help digest the enhanced logs.
72a6fa9 @noahd1 adding to the documentation
authored
12
697d37e @noahd1 adding to documentation
authored
13 Given a minimum threshold and a metric (memory or active record instantiation), the oink executable reports:
e91541b @noahd1 documentation
authored
14
697d37e @noahd1 adding to documentation
authored
15 1. The top ten single requests which exceeded the threshold for the metric, ordered by the request which exceeded the threshold the most
16 2. The number of times each action exceeded the threshold for the metric, ordered by the action which exceeded the threshold the most
e91541b @noahd1 documentation
authored
17 3. (in verbose mode) The log lines produced by requests which exceeded the threshold
18
697d37e @noahd1 adding to documentation
authored
19 Many thanks to Ben Johnson for Memory Usage Logger (http://github.com/binarylogic/memory_usage_logger/tree/master) which is the basis of this plugin.
20
e91541b @noahd1 documentation
authored
21 == Dependencies
22
697d37e @noahd1 adding to documentation
authored
23 Currently oink can only parse logs in the Hodel3000Logger format
e91541b @noahd1 documentation
authored
24
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
25 - http://github.com/topfunky/hodel_3000_compliant_logger
72a6fa9 @noahd1 adding to the documentation
authored
26
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
27 When used as a gem, this is automatically brought in as a dependency.
e91541b @noahd1 documentation
authored
28
1831737 update README
Noah Davis authored
29 === Installation
697d37e @noahd1 adding to documentation
authored
30
1831737 update README
Noah Davis authored
31 Add oink to your Gemfile
5e59d82 @noahd1 fixed bug with bad memoization of total active record instantiation c…
authored
32
bfbde74 Updated Installation section of README with code block
Chris Ledet authored
33 gem "oink"
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
34
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
35 In most rails environments this is sufficient and oink will be required for you via bundler.
36 If not, add a require statement "require 'oink'" in your app.
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
37
1831737 update README
Noah Davis authored
38 === Configuration
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
39
1831737 update README
Noah Davis authored
40 Oink is middleware for instrumentation during the runtime of your application as well as log parsers for offline crunching of the logs generated by
41 the middleware.
e91541b @noahd1 documentation
authored
42
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
43 The middleware class to include into your stack is "Oink::Middleware". For rails using an initializer is recommended:
5e59d82 @noahd1 fixed bug with bad memoization of total active record instantiation c…
authored
44
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
45 YourApplication::Application.middleware.use Oink::Middleware
697d37e @noahd1 adding to documentation
authored
46
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
47 Oink::Middleware writes log entries to log/oink.log in your application root directory by default.
8c8b933 Update documentation
Eirik Dentz Sinclair & Noah Davis authored
48
49 You can also initialize it with an optional logger instance enabling your application to write Oink log entries to your application's default log file:
e91541b @noahd1 documentation
authored
50
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
51 YourApplication::Application.middleware.use( Oink::Middleware, :logger => Rails.logger )
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
52
8c8b933 Update documentation
Eirik Dentz Sinclair & Noah Davis authored
53 (This setup enables Oink to work with Request Log Analyzer (https://github.com/wvanbergen/request-log-analyzer), which currently parses rails logs)
54
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
55 Oink::Middleware logs memory and activerecord usage by default.
8c8b933 Update documentation
Eirik Dentz Sinclair & Noah Davis authored
56
57 You can configure which using the :instruments option. For memory only:
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
58
9b7bb2e allow instruments option to middleware to take a single argument in a…
Eirik Dentz Sinclair & Noah Davis authored
59 YourApplication::Application.middleware.use( Oink::Middleware, :instruments => :memory )
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
60
8c8b933 Update documentation
Eirik Dentz Sinclair & Noah Davis authored
61 For activerecord instantiation counts only:
62
9b7bb2e allow instruments option to middleware to take a single argument in a…
Eirik Dentz Sinclair & Noah Davis authored
63 YourApplication::Application.middleware.use( Oink::Middleware, :instruments => :activerecord )
8c8b933 Update documentation
Eirik Dentz Sinclair & Noah Davis authored
64
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
65 Note that the previous way of configuring oink, as a set of modules to include into rails controllers, is deprecated.
5e59d82 @noahd1 fixed bug with bad memoization of total active record instantiation c…
authored
66
1831737 update README
Noah Davis authored
67 == Analyzing logs
5e59d82 @noahd1 fixed bug with bad memoization of total active record instantiation c…
authored
68
1831737 update README
Noah Davis authored
69 After installing the plugin and aggregating some enhanced logs, run the 'oink' executable against your server logs.
697d37e @noahd1 adding to documentation
authored
70
f2b07bd @noahd1 documentation formatting
authored
71 Usage: oink [options] files
697d37e @noahd1 adding to documentation
authored
72 -t, --threshold [INTEGER] Memory threshold in MB
73 -f, --file filepath Output to file
74 --format FORMAT Select format
75 (ss,v,s,verbose,short-summary,summary)
76 -m, --memory Check for Memory Threshold (default)
77 -r, --active-record Check for Active Record Threshold
78
79 Oink hunts for requests which exceed a given threshold. In "memory" mode (the default), the threshold represents a megabyte memory increase from the previous request. In "active record" mode (turned on by passing the --active-record switch), the threshold represents the number of active record objects instantiated during a request.
72a6fa9 @noahd1 adding to the documentation
authored
80
81 e.g. To find all actions which increase the heap size more than 75 MB, where log files are location in /tmp/logs/
82
f2b07bd @noahd1 documentation formatting
authored
83 $ oink --threshold=75 /tmp/logs/*
697d37e @noahd1 adding to documentation
authored
84 ---- MEMORY THRESHOLD ----
85 THRESHOLD: 75 MB
86
ba5ec1e @noahd1 adding example output to the documentation
authored
87 -- SUMMARY --
697d37e @noahd1 adding to documentation
authored
88 Worst Requests:
89 1. Feb 02 16:26:06, 157524 KB, SportsController#show
90 2. Feb 02 20:11:54, 134972 KB, DashboardsController#show
91 3. Feb 02 19:06:13, 131912 KB, DashboardsController#show
92 4. Feb 02 08:07:46, 115448 KB, GroupsController#show
93 5. Feb 02 12:19:53, 112924 KB, GroupsController#show
94 6. Feb 02 13:03:00, 112064 KB, ColorSchemesController#show
95 7. Feb 02 13:01:59, 109148 KB, SessionsController#create
96 8. Feb 02 06:11:17, 108456 KB, PublicPagesController#join
97 9. Feb 02 08:43:06, 94468 KB, CommentsController#create
98 10. Feb 02 20:49:44, 82340 KB, DashboardsController#show
99
100 Worst Actions:
101 10, DashboardsController#show
102 9, GroupsController#show
103 5, PublicPagesController#show
104 5, UsersController#show
105 3, MediaController#show
106 2, SportsController#show
ba5ec1e @noahd1 adding example output to the documentation
authored
107 1, SessionsController#create
697d37e @noahd1 adding to documentation
authored
108 1, GroupInvitesController#by_email
109 1, MediaController#index
110 1, PostsController#show
111 1, PhotoVotesController#create
ba5ec1e @noahd1 adding example output to the documentation
authored
112 1, AlbumsController#index
113 1, SignupsController#new
697d37e @noahd1 adding to documentation
authored
114 1, ColorSchemesController#show
115 1, PublicPagesController#join
116 1, CommentsController#create
ba5ec1e @noahd1 adding example output to the documentation
authored
117
e91541b @noahd1 documentation
authored
118 e.g. In verbose mode, oink will print out all the log information from your logs about the actions which exceeded the threshold specified
888120e @noahd1 initial commit
authored
119
643eb0c Updated example in documentation regarding how to make output verbose.
Evil Trout authored
120 $ oink --format verbose --threshold=75 /tmp/logs/*
888120e @noahd1 initial commit
authored
121
e91541b @noahd1 documentation
authored
122 ---------------------------------------------------------------------
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
123
e91541b @noahd1 documentation
authored
124 Feb 08 11:39:52 ey33-s00302 rails[9076]: Processing UsersController#show (for 11.187.34.45 at 2009-02-08 11:39:52) [GET]
125 Feb 08 11:39:52 ey33-s00302 rails[9076]: Parameters: {"action"=>"show", "id"=>"45", "controller"=>"users"}
126 Feb 08 11:39:52 ey33-s00302 rails[9076]: Rendering template within layouts/application
127 Feb 08 11:39:52 ey33-s00302 rails[9076]: Rendering users/show
128 Feb 08 11:39:54 ey33-s00302 rails[9076]: Completed in 2008ms (View: 1136, DB: 264) | 200 OK [http://www.example.com/users/45]
cc37a73 Update README with Oink::Middleware configuration options and changes…
Eirik Dentz Sinclair & Noah Davis authored
129 Feb 08 11:39:52 ey33-s00302 rails[9076]: Oink Action: users#show
130 Feb 08 11:39:54 ey33-s00302 rails[9076]: Memory usage: 316516 | PID: 9076
131 Feb 08 11:39:54 ey33-s00302 rails[9076]: Oink Log Entry Complete
e91541b @noahd1 documentation
authored
132 ---------------------------------------------------------------------
133
134 Verbose format prints the summary as well as each action which exceeded the threshold.
888120e @noahd1 initial commit
authored
135
136 === Authors
137
138 - Maintained by Noah Davis
86e27bc @technicalpickles Refactored to be usuable as a gem, and updated documentation.
technicalpickles authored
139 - Thanks to Weplay (http://weplay.com) for sponsoring development and supporting open sourcing it from the start
Something went wrong with that request. Please try again.