Skip to content

Getting Started

jool edited this page Nov 17, 2014 · 1 revision

First Steps

To obtain and compile ponos:

$ git clone https://github.com/klarna/ponos
$ cd ponos
$ make

Next, start an erlang shell and provide the path to the compiled code:

erl -pa ebin

Finally, start the application with application:start(ponos), or ponos:start().

Adding Your First Load Generator

The most important concept in ponos is the load_generator. You can add as many load generators as you have RAM and CPU cycles to spare. In its simplest form, there are only three required parts that every load generator must have:

  • name - a unique reference of type atom() used to reference the load generator.
  • load_spec - The load specification defines the characteristic of the load. It is a function that maps time to intensity: fun(T) -> I where T is passed time in milliseconds and I is the intensity expressed as calls per second. The user may define its own specification, but ponos provides typical load patterns such as constant load, bursts, staircase, and sawtooth.
  • task - the task is what gets applied when the load generator decides it is time to trigger load (by consulting the load_spec) The load generator applies tasks asynchronously. By default, task is expected to be of arity 0, but this limitation can be overcome by resorting to implementing your own task runner.

Here is an example:

1> application:start(ponos).
ok
2> Name = robert,                                                
2> LoadSpec = ponos_load_specs:make_constant(30.0),              
2> Task = fun() -> {ok, mike} end,                               
2> LoadGen = [{name, Name}, {load_spec, LoadSpec}, {task, Task}],
2> ponos:add_load_generators(LoadGen).                           
[ok]
3> ponos:init_load_generators(robert).
[ok]

You can monitor all your load generators through the ptop module:

4> ptop:pp().

Procs/Limit: 31/262144
Ports/Limit: 4/65536
================================================================================ 
Name        | Running | Load  | Modeled | No Calls   | Duration   | Run Time  
-------------------------------------------------------------------------------- 
robert      | y(0)    | 30.2  | 30.0    | 2193       | infinity   | 00:01:13
-------------------------------------------------------------------------------- 
     total:           | 30.2  | 30.0    | 2193      
================================================================================ 
ok

A More Advanced Example

Clone this wiki locally