Reference

# Pricing

Metered billing in rngo is based upon simulation volume. At the end of each billing period, usage equals the aggregate volume of all simulations run within that period.

## Simulation Volume

A simulation's volume is the sum of each *stream's* volume, which is calculated by taking the product of:

**stream length**- the maximum number of events that the stream could produce given the simulation specs.**schema width**- the number of bytes required to store the largest value described by the stream's schema.

The volume is this number rounded up to the next megabyte.

## Stream Length

A stream's length is the maximum number of events that the stream could produce given the simulation specs.

### Fixed Rate

If the stream has a fixed rate, the length is the rate multiplied by the simulation duration in seconds.

### Variable Rate

If the stream has a variable rate, the length is calulated by partitioning the domain of the function and summing the maximum of each partition's upper- and lower-bound rate.

See the Streams reference for more on rates.

## Schema Width

A schema's width is the number of bytes required to store the largest value described by the schema.

### Null

A `null`

schema's width is 1.

### Boolean

A `boolean`

schema's width is 1.

### Integer

An `integer`

schema's width is large enough to fit it's upper bound. For example, the following schema has width 3:

```
type: integer
maximum: 65600
```

The width must also accommodate the lower bound - this schema also has width 3:

```
type: integer
minimum: -65600
maximum: 128
```

Upper and lower bounds may also be derived from the `exclusiveMinimum`

, `exclusiveMaximum`

, `enum`

and `const`

keywords, along with from rngo value expressions.

If no bounds are specified, we use a default `minimum`

of `-2147483648`

and a `maximum`

of `2147483647`

, so the following schema has a width of 4:

```
type: integer
```

### Number

A `number`

schema's values are represented as integers, with the 4 least significant digits representing the fractional part. So the following schema has a width of 3:

```
type: number
minimum: 0
maximum: 32
```

This is because the largest possible value is represented as 320000, which requires 3 bytes. This schema has width of 4 to accomodate the integer 20458900:

```
type: number
minimum: -2045.89
maximum: 32
```

### String

A `string`

schema's width is the length of the longest possible string multiplied by 4, so this schema has a width of 80:

```
type: string
maxLength: 20
```

If a `string`

has an `enum`

(or a `const`

), the width will be the item with the most bytes. For example, this schema has length 5:

```
type: string
enum:
- one
- two
- three
```

The width may also be derived from the `pattern`

and `format`

keywords, along with from rngo value expressions.

If no keywords are specified, we use a default `maxLength`

value of `64`

, meaning ther following schema has a width of 256:

```
type: string
```

### Array

An `array`

schema's width is the maximum length of the array times the size of its items. So the following schema has a width of 5:

```
type: array
items:
type: integer
minimum: 0
maximum: 128
maxItems: 5
```

If `maxItems`

is not specified, we use a default value of `64`

### Object

An `object`

schema's width is the sum of the width of its values. This schema has a width of 19:

```
type: object
properties:
id:
type: integer
mimum: 0
maximum: 512
name:
type: string
maxLength: 4
admin:
type: boolean
```

Widths are calculated recursively, so the following schema has a width of 127:

```
type: object
properties:
id:
type: integer
posts:
type: array
items:
type: object
properties:
title:
type: string
maxLength: 10
published:
type: boolean
maxItems: 3
```