Use folly::dynamic::object and folly::dynamic::string exclusivly
[hiphop-php.git] / hphp / doc / server.stats
blobe4bc438317c22ea10ef14d041f96d1f890de4280
2 <h2>Server Stats</h2>
4 For each page, we collect stats by time slots. Each time slot is configured as
5 StatsSlotDuration seconds and server internally keeps StatsMaxSlot number of
6 slots. Inside each slot, we keep a set of stats by page or URL. These stats
7 include 3 built-in ones ("url", "code" and "hit") and many key-value pairs
8 defined by different parts of the system.
10   slot:
11     time:
12     pages:
13       page:
14         url:   original URL
15         code:  return code
16         hit:   total counts
17         details:
18           key-value pair
19           key-value pair
20           key-value pair
21           ...
24 <h2>Stats Query</h2>
26 To query stats, hit admin port with a URL like this,
28   http://[server]:8088/stats.[fmt]?from=[t1]&to=[t2]...
30 from: (optional) starting time's timestamp (e.g. 1251927393),
31         - use -n for n seconds ago
32         - when omitted or 0, it will be the earliest possible time server keeps
34 to:   (optional) ending time's timestamp,
35         - use -n for n seconds ago
36         - when omitted or 0, it will be "now"
38 agg:  (optional) aggregation, can be any one of these,
39         *          aggregate all data into one list of key value pairs
40         url        aggregate all data by URLs
41         code       aggregate all data by response code
42         (omitted)  default by time slots
44 keys: (optional) comma delimited keys to query, each of which can be decorated
45         [key]      just the key's value, e.g. "sql.conn"
46         [key]/hit  average per page hit, e.g. "sql.conn/hit"
47         [key]/sec  per second rate, e.g. "sql.conn/sec"
48         #[regex]#  keys matching the regular expression
49         (omitted)  all available keys
51 url:  (optional) only output stats matching the specified URL
53 code: (optional) only output stats of pages that have response code
55 [fmt]: can be one of these:
57         xml        XML format
58         json       JSON format
59         kvp        simple key-value pairs in JSON format, assuming agg=*
62 <h2>Available Keys</h2>
64 1. SQL Stats:
66 (1) Connections
68 sql.conn:       number of connections newly created
69 sql.reconn_new: number of connections newly created when trying to reconnect
70 sql.reconn_ok:  number of connections re-picked up when trying to reconnect
71 sql.reconn_old: number of connections dropped when trying to reconnect
73 (2) Queries
75 sql.query:                number of queries executed
76 sql.query.[table].[verb]: per table-verb stats
77 sql.query.[verb]:         per verb stats, where [verb] can be one of these:
79 - select
80 - insert
81 - update
82 - replace
83 - delete
84 - begin
85 - commit
86 - rollback
87 - unknown
89 2. MemCache Stats:
91 mcc.madd:           number of multi_add() calls
92 mcc.madd.count:     total count of multi added keys
93 mcc.mreplace:       number of multi_replace() calls
94 mcc.mreplace.count: total count of multi replaced keys
95 mcc.set:            number of set() calls
96 mcc.add:            number of add() calls
97 mcc.decr:           number of decr() calls
98 mcc.incr:           number of incr() calls
99 mcc.delete:         number of delete() calls
100 mcc.delete_details: number of delete_details() calls
101 mcc.get:            number of get() calls
102 mcc.mget:           number of multi_get() calls
103 mcc.mget.count:     total count of multi got keys
104 mcc.replace:        number of replace() calls
105 mcc.set:            number of set() calls
106 mcc.stats:          number of stats() calls
108 3. APC Stats:
110 apc.miss:   number of item misses
111 apc.hit:    number of item hits
112 apc.update: number of item updates
113 apc.new:    number of new items
114 apc.erased: number of successfully erased items
115 apc.erase:  number of items that failed to erase (because they were absent)
116 apc.inc:    number of inc() call
117 apc.cas:    number of cas() call
119 4. Memory Stats:
121 These two stats are only available when Google heap profler is turned on for
122 debugging purposes:
124 mem.malloc.peak:   peak malloc()-ed memory
125 mem.malloc.leaked: leaked malloc()-ed memory
127 5. Page Sections:
129 page.wall.[section]:   wall time a page section takes
130 page.cpu.[section]:    CPU time a page section takes
131 mem.[section]:         SmartAllocator memory a page section takes
132 network.uncompressed:  total bytes to be sent before compression
133 network.compressed:    total bytes sent after compression
135 Section can be one of these:
137 - queuing
138 - all
139 - input
140 - invoke
141 - send
142 - psp
143 - rollback
144 - free
146 6. evhttp Stats:
148 - evhttp.hit              used cached connection
149 - evhttp.hit.[address]    used cached connection by URL
150 - evhttp.miss             no cached connection available
151 - evhttp.miss.[address]   no cached connection available by URL
152 - evhttp.close            cached connection got closed
153 - evhttp.close.[address]  cached connection got closed by URL
154 - evhttp.skip             not set to use cached connection
155 - evhttp.skip.[address]   not set to use cached connection by URL
157 7. Application Stats:
159 PHP page can collect application-defined stats by calling
161   hphp_stats($key, $count);
163 where $key is arbitrary and $count will be tallied across different calls of
164 the same key.
166 8. Special Keys:
168 hit:   page hit
169 load:  number of active worker threads
170 idle:  number of idle worker threads
173 <h2>Example URL</h2>
175   GET "http://localhost:8088/stats.kvp?prefix=hphp&agg=*" \
176     "&keys=apc.hit/sec,hit,load,:sql.query..*.select:," \
177     "network.compressed/hit,hit/sec"
179 This URL queries the following data:
181 hit:                        page hits
182 hit/sec:                    request per second
183 apc.hit/sec:                APC hit per second
184 load:                       number of active threads currently
185 network.compressed/hit:     sent bytes per request
186 :sql.query..*.select:       all SELECTs on different tables