# The `api/perf` Resource

> The `api/perf` resource reports the performance statistics described below.

> ### For an overview see page eXtremeDB Web Service Resources

> In order to enable access to eXtremeDB performance statistics the performance monitor must be enabled and the REST server must be started. When using xSQL to start the REST server, the performance monitor is explicitly enabled in the configuration file. For example:

>         database_name : xsqldb,
>         database_size : 100m,

>         perfmon : {
>             database_size : 64m
>         },

>         rest : {
>             addr : 127.0.0.1,
>             port : 8083
>         }

> Note that, for the `perf` resource, the `perfmon` section must be included in the xSQL configuration file. (See page xSQL Web Services REST Parameters for further information).

> With `perfmon` enabled, and the REST server started with port 8083, the following http request will return a list of the available performance statistics:

>         http://localhost:8083/api/perf

> Performance statistics are of two types: `counters` and `timings`. The `readings` array displays the `name`, `description` and index number `no` for each `counter` and `timing` in the following format:

>         {

>         "databases":

>         [
>             {

>                 "name": "xsqldb",

>                 "no": 0

>             }
>         ],
>         "nodes":
>         [
>         ],
>         "readings":
>         [
>             {
>                 "name": "MCO_PERF_ERROR_COUNT",
>                 "description": "Error count",
>                 "type": "counter",
>                 "no": 0
>             },
>             ...
>             {
>                 "name": "MCO_PERF_DB_CACHE_PAGES_WRITE_DELAYED",
>                 "description": "",
>                 "type": "counter",
>                 "no": 24
>             },
>             ...
>             {
>                 "name": "MCO_PERF_DISK_READ_TIME",
>                 "description": "Disk read time",
>                 "type": "timing",
>                 "no": 100
>             },
>             ...
>             {
>                 "name": "MCO_PERF_CLUSTER_NET_RECV_TIME",
>                 "description": "",
>                 "type": "timing",
>                 "no": 107
>             }
>         ]

>         }

> Individual counter values can be requested by specifying the index of the counter desired. (See the Request Parameters section below for further details.)

> ## Counters

> The following table lists the available `counters`:

> Index No | Name | Description
> --- | --- | ---
> 0 | MCO_PERF_ERROR_COUNT | The error count
> 1 | MCO_PERF_CONNECTION_COUNT | The current number of database connections
> 2 | MCO_PERF_CONNECTS | The number of database connection requests
> 3 | MCO_PERF_DISCONNECTS | The number of database disconnection requests
> 4 | MCO_PERF_HOST_CPU_LOAD | The CPU load
> 5 | MCO_PERF_HOST_MEMORY | The host memory usage
> 6 | MCO_PERF_OPEN_TRANS_COUNT | The number of opened transactions
> 7 | MCO_PERF_OPEN_CURSOR_COUNT | The number of cursors
> 8 | MCO_PERF_LAST_SNAPSHOT_SIZE | The size of the last saved database snapshot
> 9 | MCO_PERF_MAX_CONNECTIONS | The maximum number of database connections
> 10 | MCO_PERF_DB_TOTAL_PAGES | The total number of memory pages
> 11 | MCO_PERF_DB_FREE_PAGES | The number of free pages
> 12 | MCO_PERF_DB_MEMORY | The number of used pages
> 13 | MCO_PERF_DB_FILE_SIZE | The total database file size
> 14 | MCO_PERF_DB_LOG_FILE_SIZE | The log file size
> 15 | MCO_PERF_DB_USED_FILE_SIZE | The used database file size
> 16 | MCO_PERF_DB_CACHE_HIT_COUNT | The disk cache hit count
> 17 | MCO_PERF_DB_CACHE_MISS_COUNT | The disk cache miss count
> 18 | MCO_PERF_DB_CACHE_PAGES_ALLOCATED | The total number of allocated cache pages
> 19 | MCO_PERF_DB_CACHE_PAGES_USED | The number of cache pages used
> 20 | MCO_PERF_DB_CACHE_PAGES_PINNED | The number of pinned (non-swappable) cache pages
> 21 | MCO_PERF_DB_CACHE_PAGES_MODIFIED | The number of cache pages modified by active transactions
> 22 | MCO_PERF_DB_CACHE_PAGES_DIRTY | The number of dirty cache pages
> 23 | MCO_PERF_DB_CACHE_PAGES_COPIED | The number of copies of original pages
> 24 | MCO_PERF_DB_CACHE_PAGES_WRITE_DELAYED | The number of write delayed pages

> ## Timings

> The following table lists the available `timings`:

> Index No | Name | Description
> --- | --- | ---
> 100 | MCO_PERF_DISK_READ_TIME | The disk read time
> 101 | MCO_PERF_DISK_WRITE_TIME | The disk write time
> 102 | MCO_PERF_LOG_WRITE_TIME | The log write time
> 103 | MCO_PERF_COMMIT_TIME | The commit time
> 104 | MCO_PERF_ROLLBACK_TIME_AVG | The rollback time
> 105 | MCO_PERF_SNAPSHOT_DURATION | The snapshot duration
> 106 | MCO_PERF_CLUSTER_NET_SEND_TIME | The cluster network data write time
> 107 | MCO_PERF_CLUSTER_NET_RECV_TIME | The cluster network data read time

> ## Request Parameters

> The `/api/perf/counters`,`/api/perf/timings` requests show perf `counter` and `timing` readings. These resources support the following query parameters:

> - `db`: database number.
> - `count`: maximum number of readings to return.
> - `counter`: index of the reading to get from the arrays; all readings if not set.
> - `node`: node number.
> - `period`: amount of time to return readings for, msec.
> - `since`: timestamp to retrieve readings after.

> The `period` and `since` parameters are mutually exclusive and cannot be used together. If none of the `count`, `since` or `period` parameters are specified, only the latest reading is returned.

> The `counter` parameter corresponds to the `no` key in the reading descriptions above. The `db` parameter corresponds to the `no` key in the database description above.

> The following snippet is an example of a `counter` reading for the request `http://localhost:8083/api/perf/counters?db=0`:

>         {
>             "now": 1514548579967,
>             "counters":
>             [
>                 {
>                     "stamp": 1514548579792,
>                     "db": 0,
>                     "node": 0,
>                     "values":
>                     [
>                         0, 7, 0, 0, 0, 23, 0, 0, 0, 100, 406786, 406735, 3, 122880, 73940
>                     ]
>                 }
>             ]
>         }

> The following snippet is an example of a `timing` reading for the request `http://localhost:8083/api/perf/timings?db=0`::

>         {
>             "now": 1514548622065,
>             "timings":
>             [
>                 {
>                     "stamp": 1514548621908,
>                     "db": 0,
>                     "node": 0,
>                     "values":
>                     {
>                         "current":
>                         [
>                             0, 0, 0, 0, 0, 0, 0, 0
>                         ],
>                         "min":
>                         [
>                             0, 0, 0, 0, 0, 0, 0, 0
>                         ],
>                         "max":
>                         [
>                             0, 0, 0, 0, 0, 0, 0, 0
>                         ],
>                         "avg":
>                         [
>                             0, 0, 0, 0, 0, 0, 0, 0
>                         ],
>                         "total":
>                         [
>                             0, 0, 0, 0, 0, 0, 0, 0
>                         ],
>                         "count":
>                         [
>                             0, 0, 0, 0, 0, 0, 0, 0
>                         ]
>                     }
>                 }
>             ]
>         }