Package for profiling WSGI applications on production
Project description
[![CircleCI](https://circleci.com/gh/fieldaware/liveprofiler.svg?style=svg)](https://circleci.com/gh/fieldaware/liveprofiler)
[![PyPI version](https://badge.fury.io/py/liveprofiler.svg)](https://badge.fury.io/py/liveprofiler)
# Liveprofiler visualizer and collector
This is a service that collects and presents samples generated by [livepofier_sampler](https://github.com/fieldaware/liveprofiler_sampler).
It is follow up work based on https://github.com/nylas/nylas-perftools. So most of the credit goes to: nylas.com
To really understand what is going on here check this great blog post: https://www.nylas.com/blog/performance
# Overview
```
web client
service one<----------------+ +
| |
+ v
service two<-----------+collector+--------+ visualizer
+ | ^
| v |
service three<--------------+ database+--------+
```
* each service runs liveprofiler_sampler middleware
* collector pulls metrics from services and saves them to python dbm database
* visualizer reads dbm database and plots the results per host
# Collector
Collector is responsible for gathering samples for configured hosts. Because sampler is protected with secret header, it has to be configured in collector as well. Collector should be called periodically (every few seconds). If you are planning to run collector with uWSGI (recommended) see running with uWSGI section. If not, you can set up cron to call `collector/` endpoint. It will return number of collected samples from all hosts.
```
[collector]
secret_header = {SECRET HEADER}
hosts= {LIST OF HOSTS SEPARATED BY COMMA (host1,host2,host3)}
```
# Visualizer
Uses flame graph to plot stacks and their counts.
![visualized samples](visualizer.png "Example visualization")
# Example
If you provide sampler configuration you can plot samples for the visualizer itself - it is a nice self-contained demo.
This is a snippet from the `example/config.ini`
```
[global]
dbpath = /tmp/liveprofiler/
[collector]
secret_header = samplers3cr3t
hosts=localhost:9999
[sampler]
enabled = 1
interval = 0.01
secret_header = samplers3cr3t
```
* `secret_header` is the same on the both sides.
* If sampler configuration is not provided or if the sampler is not enabled no metrics will be collected
To run the example, create virtualenv and install dependencies from requirements.txt (`pip install -r requirements.txt`)
To run the server:
```
> uwsgi example/uwsgi.ini
```
Then visit `http://localhost:9999/`.
# uWSGI integration
* Use at least 2 workers (processes) to run visualizer - one for visualizer and one for collector
* Visualizer uses [uWSGI decorators](http://uwsgi-docs.readthedocs.io/en/latest/PythonDecorators.html) to schedule collector calls - therefore `master = true` has to be enabled in uWSGI configuration
* `app_config` is a path to the visualizer configuration file - it must be set and it recommend it be an absolute path
* if you are running visualizer with sampler enabled please check required uWSGI configuration to make it running
[![PyPI version](https://badge.fury.io/py/liveprofiler.svg)](https://badge.fury.io/py/liveprofiler)
# Liveprofiler visualizer and collector
This is a service that collects and presents samples generated by [livepofier_sampler](https://github.com/fieldaware/liveprofiler_sampler).
It is follow up work based on https://github.com/nylas/nylas-perftools. So most of the credit goes to: nylas.com
To really understand what is going on here check this great blog post: https://www.nylas.com/blog/performance
# Overview
```
web client
service one<----------------+ +
| |
+ v
service two<-----------+collector+--------+ visualizer
+ | ^
| v |
service three<--------------+ database+--------+
```
* each service runs liveprofiler_sampler middleware
* collector pulls metrics from services and saves them to python dbm database
* visualizer reads dbm database and plots the results per host
# Collector
Collector is responsible for gathering samples for configured hosts. Because sampler is protected with secret header, it has to be configured in collector as well. Collector should be called periodically (every few seconds). If you are planning to run collector with uWSGI (recommended) see running with uWSGI section. If not, you can set up cron to call `collector/` endpoint. It will return number of collected samples from all hosts.
```
[collector]
secret_header = {SECRET HEADER}
hosts= {LIST OF HOSTS SEPARATED BY COMMA (host1,host2,host3)}
```
# Visualizer
Uses flame graph to plot stacks and their counts.
![visualized samples](visualizer.png "Example visualization")
# Example
If you provide sampler configuration you can plot samples for the visualizer itself - it is a nice self-contained demo.
This is a snippet from the `example/config.ini`
```
[global]
dbpath = /tmp/liveprofiler/
[collector]
secret_header = samplers3cr3t
hosts=localhost:9999
[sampler]
enabled = 1
interval = 0.01
secret_header = samplers3cr3t
```
* `secret_header` is the same on the both sides.
* If sampler configuration is not provided or if the sampler is not enabled no metrics will be collected
To run the example, create virtualenv and install dependencies from requirements.txt (`pip install -r requirements.txt`)
To run the server:
```
> uwsgi example/uwsgi.ini
```
Then visit `http://localhost:9999/`.
# uWSGI integration
* Use at least 2 workers (processes) to run visualizer - one for visualizer and one for collector
* Visualizer uses [uWSGI decorators](http://uwsgi-docs.readthedocs.io/en/latest/PythonDecorators.html) to schedule collector calls - therefore `master = true` has to be enabled in uWSGI configuration
* `app_config` is a path to the visualizer configuration file - it must be set and it recommend it be an absolute path
* if you are running visualizer with sampler enabled please check required uWSGI configuration to make it running
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file liveprofiler-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: liveprofiler-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 94.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9828f2e1bcd3a143e74a7e2fe9928fc7a32ed5071c0a855623603c426d076272 |
|
MD5 | d9aa4266f75ef0cff633993aef259f0a |
|
BLAKE2b-256 | a820542da326c0febce1060a44c73db1a324fb49f8d2a5f5b0ee79914a4b955c |