• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Erlang
  • License
    Apache License 2.0
  • Created about 10 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ponos is a simple yet powerful load generator written in erlang
                   _____   ____  _   _  ____   _____
                  |  __ \ / __ \| \ | |/ __ \ / ____|
                  | |__) | |  | |  \| | |  | | (___
                  |  ___/| |  | | . ` | |  | |\___ \
                  | |    | |__| | |\  | |__| |____) |
                  |_|     \____/|_| \_|\____/|_____/

Description

Ponos is an Erlang application that exposes a flexible load generator API. Ponos [1] is named after the Greek god of hard labor and toil (http://en.wikipedia.org/wiki/Ponos).

Written by Jonathan Olsson [email protected] with contributions from Cons Γ…hs [email protected]

Resources

The main place to find information about ponos is the github page.

Documentation is available as edoc as well as on the ponos wiki.

Quick Start Guide

$> git clone https://github.com/klarna/ponos.git
$> cd ponos
$> make
$> erl -pa ebin -s ponos
1> Args = [ {name, unique_name_of_type_atom}
1>        , {task, fun() -> ok end}
1>        , {load_spec, ponos_load_specs:make_constant(10.0)}
1>        ].
2> ponos:add_load_generators([Args]).
3> ponos:init_load_generators().
4> application:stop(ponos).

Introduction

Ponos is a simple yet powerful erlang application used to generate load at configurable frequencies. It's designed to be lightweight, straight forward to use and to require minimal configuration.

Load Generators

There are only three required parts of a load generator:

  • Name
    • A unique identifier (of type atom()) used to reference the load generator.
  • Task
    • A callback function of arity 0; the work to be performed in accordance with LoadSpec.
  • LoadSpec
    • 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. See ponos_load_specs for a full list of load specifications.

Adding and Starting Load Generators

1> Name = foo.
2> Task = fun() -> do_your_thing end.
3> LoadSpec = ponos_load_specs:make_sawtooth(10, 20.0).
4> Options = [{duration, 60*1000}, {auto_init, false}].
5> Args = [{name,Name},{task,Task},{load_spec,LoadSpec},{options,Options}].
6> [ok] = ponos:add_load_generators([Args]).
7> ponos:init_load_generators([Name]).

ponos:add_load_generators/1 takes a list of proplists where each proplist denotes the arguments needed to add a new load generator to ponos. The options argument is optional, and may contain all or none of the available options.

Options:

  • auto_init - Defaults to false. If set to true, the load generator will start generating load immediately. Otherwise ponos:init_load_generators/0|1 have to be called to start generating load.
  • duration - Defaults to infinity. By default the load generator will run until removed or paused. If set to a pos_integer, the load generator will generate load for that many milliseconds.
  • max_concurrent - An integer() used to limit how many concurrently ongoing tasks the load generator may spawn. Note that this potentially affects the intensity in a negative way, i.e. you may get a lower output than the load_spec describes. By default, the load generator may have an infinite amount of concurrently ongoing tasks.
  • task_runner - Defaults to ponos_default_task_runner. Must be a module() implementing the ponos_task_runner_callbacks behaviour.
  • task_runner_args - Defaults to []. May be of type any(). The value is passed to the task_runner's init function.

For convenience, all operations on load generators permits referring to a single load generator or a list of generators.

ponos_load_specs

This module provides a set of predefined constructors for typical load patterns. A load specification defines the characteristics of load and is implemented as 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 implement its own load specifications.

A Note About Sampling Intervals and Timers

A load generator is implemented as a gen_server receiving a tick every millisecond. The LoadSpec - which is a function of time - thus gets sampled at every tick to determine whether load should be sent or not. At each tick the load generator may decide to generate multiple calls, so it is - at least in theory - possible to produce arbitrary large amount of cps.

In practice however the load generator itself will become CPU limited above a point that depends on your CPU and/or OS. It is better to use two - or more - generators to leverage the power of multi-core CPUs if such high load is required.

There are other factors that may prevent a load generator to exactly reproduce the specified load pattern.

One of the factors is how timers are implemented in the Erlang VM: a timer may never fire early, but may get delayed indefinitely. This means when the load generator decides to sleep for 1 ms, it will usually end up sleeping for somewhat longer. This will reduce the actual sampling frequency of the LoadSpec. Even if the system is not otherwise overloaded you may not assume sampling frequencies above 500 Hz in practice.

The other limiting factor is that the load generator will favor higher intensities over lower ones when the LoadSpec is not constant. This effect is best explained via an example.

Consider a LoadSpec that for even seconds specifies intensity 0.5 and for odd seconds 4.0. This means ponos will try to trigger tasks at 1000, 1250, 1500, 1750, and 3000 milliseconds. The actual intensity will be therefore 4.0 for odd seconds, but for even seconds it will only fall to 0.8, not to 0.5. The low intensity interval is simply too short.

Task Runners

In essence, ponos gathers load generators under a supervisor and makes sure they get a chance to execute their task at the requested interval. Instead of executing the task itself, ponos hands over to a task runner at certain points, e.g. when it is time to trigger a task. For convenience, ponos provides two implementations of the ponos_task_runner_callbacks interface:

  • ponos_default_task_runner - takes no extra arguments and simply applies the provided Task.
  • ponos_file_task_runner - applies the provided Task as well as logs the various events to file.

The ponos_task_runner_callbacks behaviour defines the following interface:

ponos_task_runner_callbacks behaviour
call(Name, Task, State) -> ok
concurrency_limit(Name, State::any()) -> ok
init(Name, Args) -> {ok, State::any()}
pause(Name, State) -> ok
start(Name, State) -> {ok, NewState::any()
terminate(Name, State) -> ok

The API allows for modifying the state of the task runner at two occasions: init and start. In all other instances, the task runner may view the state but has no possibility to modify it.

Please refer to ponos_default_task_runner.erl and ponos_file_task_runner. for further reference.

Versioning

Ponos is versioned according to semantic versioning.

Notes

[1] The author is aware of the Russian meaning of the word ponos. I leave it to the Russian to fight this down with the Greek. Needless to say, a suitable name is a suitable name.

More Repositories

1

electron-redux

Use redux in the main and browser processes in electron
JavaScript
743
star
2

ui

[Archived] πŸ”© Klarna's UI components library
JavaScript
210
star
3

circuit_breaker

πŸ’₯ An Erlang library for breaking out of faulty services
Erlang
180
star
4

mnesia_eleveldb

An eleveldb backend for Mnesia
Erlang
155
star
5

jesse

This repository is no longer actively maintained, please see
Erlang
135
star
6

erlavro

Avro support for Erlang/Elixir (http://avro.apache.org/)
Erlang
130
star
7

higher-order-components

A collection of useful React higher-order components
JavaScript
129
star
8

system_monitor

BEAM VM telemetry collector
Erlang
70
star
9

product-page-dataset

49
star
10

bec

The BitBucket Erlang Client
Erlang
47
star
11

snabbkaffe

Collection of utilities for trace-based testing
Erlang
45
star
12

brucke

Brucke - Inter-cluster bridge of kafka topics
Erlang
44
star
13

katt

This repository is no longer actively maintained, please see
Erlang
42
star
14

mnesia_pg

Postgres backend to Mnesia via mnesia_ext
Erlang
41
star
15

kco-mobile-sdk

[Deprecated] Klarna Checkout SDK for mobile apps in iOS and Android
HTML
38
star
16

kco_php

DEPRECATED: Klarna Checkout PHP library
PHP
33
star
17

leveldb_manager

Small service for snapshotting eleveldb without stopping the Erlang node
Erlang
32
star
18

kco_rest_php

[DEPRECATED] Official PHP SDK library for Klarna Services
PHP
31
star
19

klarna-mobile-sdk

Klarna Mobile SDK for iOS
Objective-C
28
star
20

remote-frames

Render a subset of the React tree to a different location, from many locations, without having to coordinate them
JavaScript
27
star
21

kastle

Kafka REST proxy
Erlang
27
star
22

kco_rest_java

[DEPRECATED] Official Java SDK library for Klarna Services
Java
24
star
23

react-native-zlib

Inflate/Deflate data compression via native code.
Java
24
star
24

react-native-klarna-inapp-sdk

Klarna's React Native wrapper for the In-App SDK
Kotlin
22
star
25

geofences-reducer

Reduces overlapping geofences
TypeScript
20
star
26

kco_rest_dotnet

[DEPRECATED] Official .NET.Core SDK library for Klarna Services
C#
20
star
27

avlizer

Avro Data Serializer for Erlang
Erlang
19
star
28

lager_middleman_backend

Erlang
18
star
29

soapbox

RIP: XMLRPCful microframework.
16
star
30

disable-scroll

Fix the screen to the current position and get a canvas where to draw on top of it
JavaScript
15
star
31

ui-react-components

Klarna's UI React Components
JavaScript
15
star
32

vnet

A model of a distributed Erlang network within a single VM.
Erlang
14
star
33

krc

RIP: The K Riak Client.
13
star
34

kco_python

Klarna Checkout Python Library
Python
13
star
35

klarna-mobile-sdk-flutter

Klarna's Flutter wrapper plugin for the Klarna Mobile SDK
Kotlin
10
star
36

hubot-stash-poll

Poll your Atlassian Stash repositories for pull request changes
CoffeeScript
10
star
37

klarna-on-demand-ios

Klarna On Demand SDK for iOS
Objective-C
10
star
38

graphite-erlang

A dead-simple graphite metrics writer for Erlang
Erlang
10
star
39

erl_unused_includes

Shell
10
star
40

kp-android-example-app

An example Android app to demonstrate Klarna Mobile SDK for Klarna Payments usage https://github.com/klarna/klarna-mobile-sdk
Kotlin
9
star
41

ui-css-components

Klarna's UI CSS Components
CSS
9
star
42

php-xmlrpc

DEPRECATED: the klarna xmlrpc library for php
PHP
9
star
43

kco_dotnet

DEPRECATED: Klarna Checkout dotnet library
C#
8
star
44

klarna-on-demand-android

Klarna On Demand SDK for Android
Java
8
star
45

rimu

RIP: Riak implementations of MeshUp interfaces.
Erlang
8
star
46

cloud9-gradle-template

Template workspace structure for a Java Gradle project in Cloud9
Java
7
star
47

katt-js

KATT (Klarna API Testing Tool) is an HTTP-based testing tool for Node.
CoffeeScript
7
star
48

op5-cli

A command-line interface for the OP5 monitoring system
Python
7
star
49

day.zip

Shell
6
star
50

op5lib

A Python library for OP5's REST API.
Python
6
star
51

smoooth-tutorials

Repository hosting all code examples for the Klarna Smoooth Tutorials
JavaScript
6
star
52

kco_java

DEPRECATED:Klarna Checkout Java Library
Java
6
star
53

kp-ios-example-app

An example iOS app to demonstrate Klarna Mobile SDK for Klarna Payments usage
Swift
5
star
54

klarna.github.io

HTML
5
star
55

stdapp.mk

Generic Makefile for building Erlang applications
Makefile
5
star
56

sample-digital-goods-backend

A sample integration of Klarna's Digital Goods
Ruby
5
star
57

browser

β˜” "It is best to act with confidence, no matter how little right you have to it." Lillian Hellman
JavaScript
5
star
58

ansible-role-import-and-trust-certificate

Ansible role for importing and trusting PEM certificates.
4
star
59

on-demand-for-digital-goods-docs

4
star
60

op5lib_ansible

Python
4
star
61

cloudconfig

Cloudconfig is an application that manages configurations for resources in Cloudstack.
Ruby
4
star
62

restit

REST Interface Tool is a prototype for consuming pure REST APIs.
CoffeeScript
4
star
63

hybrid-android-example-app

Kotlin
3
star
64

m2-kco-postnl

Magento 2.x Add-On module to add support for PostNL to Klarna Checkout
JavaScript
3
star
65

katt-util

KATT utilities for KATT blueprints.
CoffeeScript
2
star
66

sample-ondemand-backend

A very slim backend that facilitates purchases for an app using the Klarna on Demand SDK.
Ruby
2
star
67

klarna-apigen-theme

Klarna ApiGen Theme
HTML
2
star
68

m1-klarna-payments

Magento 1.x Klarna Payments plugin
PHP
2
star
69

kco_asp

Klarna Checkout ASP Library
ASP
2
star
70

kp-mobile-sdk

Klarna Payments SDK for mobile apps in iOS and Android
2
star
71

sfcc-klarna-payments

Salesforce Commerce Cloud Cartdrige for Klarna Payments Integration
JavaScript
2
star
72

ui-workshop

Konferense 2016 - UI Components workshop
JavaScript
2
star
73

kco-android-example-app

An example Android app to demonstrate Klarna Checkout SDK usage
Java
2
star
74

katt-player

KATT player is a mock HTTP server that replies with HTTP responses based on KATT blueprints.
CoffeeScript
2
star
75

klarna-mobile-sdk-android

Klarna Mobile SDK for Android
2
star
76

m1-klarna-checkout

Magento 1.x Klarna Checkout plugin
PHP
1
star
77

kco-ios-example-app

An example iOS app to demonstrate Klarna Checkout SDK usage
Objective-C
1
star
78

nordicjs

A code challenge and short presentation to show at nordic.js
CSS
1
star
79

klarna-on-demand-integration-tests

Contains common integration tests for Klarna's on Demand SDKs
Ruby
1
star
80

m1-kp-altaddress

Magento 1.x Sample Add-On module to add support for EMD to Klarna Payments
PHP
1
star
81

cookbook-secretfiles

Generic way of handling encrypted files
Ruby
1
star
82

ansible-role-homebrew

Ansible role for installing Homebrew and Homebrew Cask.
1
star
83

KlarnaMobileSDKDemo

Klarna Mobile SDK demo app for iOS
Swift
1
star
84

kco-cordova-example-app

An example Cordova app to demonstrate Klarna Checkout SDK usage
Java
1
star
85

ui-prototype

A base for prototyping
JavaScript
1
star
86

passkeyring

Python
1
star
87

on-demand-for-digital-goods-python

On demand for digital goods. Simple example in Python
Python
1
star
88

gradle-react-native

Gradle Plugin for Building React Native projects
Kotlin
1
star
89

m1-kco-altaddress

Magento 1.x Sample Add-On module to add support for EMD to Klarna Checkout
PHP
1
star
90

ipx-mock

A mock for IPX SMS Service
Ruby
1
star
91

omniauth-klarna

This is the official OmniAuth strategy to authenticate with Klarna via OAuth2.
Ruby
1
star
92

react-native-klarna

A React Native wrapper around Klarna Checkout SDK
Java
1
star
93

swedish_personal_number

A Value Object that provides some convenience helpers to deal with Swedish personal numbers
Ruby
1
star