Skip to main content
Version: Next

QuotaManager

The 4D.QuotaManager class provides you with an interface to configure and monitor some usage limits you apply to your 4D application. Thresholds are useful, for example, to protect the server from poorly optimized requests or excessive use of server resources. For the REST server for example, quotas can limit the ORDA resources accessible to a REST session.

4D.QuotaManager objects can be instantiated by:

For Web server configuration and enforcement details, see Web server quotas.

History
ReleaseChanges
21 R5Support of Web server quotas
21 R4Class added

QuotaManager Object​

By default, the properties of a 4D.QuotaManager object are Undefined, meaning that no corresponding quota is applied.

The 4D.QuotaManager object itself cannot be directly assigned, and properties cannot be added to or removed from it. Quotas are configured by modifying the corresponding properties of the existing object.

4D.QuotaManager objects provide the following properties:

currentValues : Object
current usage values for the quota manager
defaultEntitySetTimeout : Integer
the default inactivity timeout for REST entity sets stored in memory during the current session (in seconds)
inBytesPerHour : Integer
the maximum total number of bytes that the Web server can receive in one hour
inBytesPerHourPerSession : Integer
the maximum total number of bytes that the Web server can receive for a session in one hour
inBytesPerMin : Integer
the maximum total number of bytes that the Web server can receive in one minute
inBytesPerMinPerSession : Integer
the maximum total number of bytes that the Web server can receive for a session in one minute
maxEntitySetTimeout : Integer
the maximum inactivity timeout value for REST entity sets stored in memory during the current session (in seconds)
nbEntitySets : Integer
the maximum number of REST entity sets allowed in memory for the current session
nbEntitySetsPerSession : Integer
the maximum number of entity sets allowed in memory for each REST session
nbGuestSessions : Integer
the maximum total number of active Guest sessions on the Web server
nbRequestsPerHour : Integer
the maximum total number of requests that the Web server can receive in one hour
nbRequestsPerHourPerSession : Integer
the maximum total number of requests that a session can receive in one hour
nbRequestsPerMin : Integer
the maximum total number of requests that the Web server can receive in one minute
nbRequestsPerMinPerSession : Integer
the maximum total number of requests that a session can receive in one minute
nbSessions : Integer
the maximum total number of active sessions on the Web server
outBytesPerHour : Integer
the maximum total number of bytes that the Web server can send in one hour
outBytesPerHourPerSession : Integer
the maximum total number of bytes that the Web server can send for a session in one hour
outBytesPerMin : Integer
the maximum total number of bytes that the Web server can send in one minute
outBytesPerMinPerSession : Integer
the maximum total number of bytes that the Web server can send for a session in one minute

.currentValues​

currentValues : Object

Description​

The .currentValues property contains current usage values for the quota manager. It is automatically updated by 4D and is read-only.

The object has the same properties as the 4D.QuotaManager object, but only the following properties report current usage:

.defaultEntitySetTimeout​

defaultEntitySetTimeout : Integer

Description​

note

This quota can only be configured for the current REST session through Session.quotas.

The .defaultEntitySetTimeout property contains the default inactivity timeout for REST entity sets stored in memory during the current session (in seconds).

Scope: current session level

By default, this value is 2 hours (7200 seconds). It can also be defined at the entity set creation using the $timeout REST API.

You can change this value dynamically using the quotas.defaultEntitySetTimeout property of the Session, so that it will be used for any entity set created afterwards in the session (existing entity set default timeout values are not modified).

note

If you define a value higher than the maxEntitySetTimeout property value, it will be aligned with the maxEntitySetTimeout value.

You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass undefined.

Example​

In some 4D code in a REST process:

Session.quotas.defaultEntitySetTimeout:=1200

.inBytesPerHour​

inBytesPerHour : Integer

Description​

The .inBytesPerHour property contains the maximum total number of bytes that the Web server can receive in one hour.

Scope: server global level

.inBytesPerHourPerSession​

inBytesPerHourPerSession : Integer

Description​

The .inBytesPerHourPerSession property contains the maximum total number of bytes that the Web server can receive for a session in one hour.

Scope: session default level

.inBytesPerMin​

inBytesPerMin : Integer

Description​

The .inBytesPerMin property contains the maximum total number of bytes that the Web server can receive in one minute.

Scope: server global level

.inBytesPerMinPerSession​

inBytesPerMinPerSession : Integer

Description​

The .inBytesPerMinPerSession property contains the maximum total number of bytes that the Web server can receive for a session in one minute.

Scope: session default level

.maxEntitySetTimeout​

maxEntitySetTimeout : Integer

Description​

note

This quota can only be configured for the current REST session through Session.quotas.

The .maxEntitySetTimeout property contains the maximum inactivity timeout value for REST entity sets stored in memory during the current session (in seconds).

Scope: current session level

You can set this value using the quotas.maxEntitySetTimeout property of the Session, so that it will be used for any entity set created afterward in the session (existing entity set maximum timeout values are not modified).

Once the .maxEntitySetTimeout property is set, any entity set created afterward in the session could not have a timeout value longer than the .maxEntitySetTimeout value.

For example, assuming the maximum inactivity timeout is set to 40 minutes (2400 seconds), if an entity set is created with a required timeout which exceeds the maximum value:

http://127.0.0.1/rest/People?$filter=ID>=4&$method=entityset&$timeout=3000

... then the timeout defined in the request is ignored and the entity set will be released after 40 minutes if not used during this period of time.

You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass undefined.

Example​

In some 4D code in a REST process:

Session.quotas.maxEntitySetTimeout:=2400

.nbEntitySets​

nbEntitySets : Integer

Description​

note

This quota can only be configured for the current REST session through Session.quotas.

The .nbEntitySets property contains the maximum number of REST entity sets allowed in memory for the current session.

Scope: current session level

By default, there is no limit for entity sets stored in memory by REST requests (the value is 0). You can set a limit to control the server payload for a specific session.

When the maximum number of allowed entity sets is reached, a REST request that need to create an entity set will get a 429 HTTP status code and an error response, until at least one entity set is released. You can release an entity set from the cache using the $release REST command.

You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass undefined.

Example​

In some 4D code in a REST process:

//max 50 entity sets
Session.quotas.nbEntitySets:=50

.nbEntitySetsPerSession​

nbEntitySetsPerSession : Integer

Description​

note

This quota applies only to a REST session.

The .nbEntitySetsPerSession property contains the maximum number of entity sets allowed in memory for each REST session.

Scope: session default level

.nbGuestSessions​

nbGuestSessions : Integer

Description​

The .nbGuestSessions property contains the maximum total number of active Guest sessions on the Web server.

Scope: server global level

.nbRequestsPerHour​

nbRequestsPerHour : Integer

Description​

The .nbRequestsPerHour property contains the maximum total number of requests that the Web server can receive in one hour.

Scope: server global level

.nbRequestsPerHourPerSession​

nbRequestsPerHourPerSession : Integer

Description​

The .nbRequestsPerHourPerSession property contains the maximum total number of requests that a session can receive in one hour.

Scope: session default level

.nbRequestsPerMin​

nbRequestsPerMin : Integer

Description​

The .nbRequestsPerMin property contains the maximum total number of requests that the Web server can receive in one minute.

Scope: server global level

.nbRequestsPerMinPerSession​

nbRequestsPerMinPerSession : Integer

Description​

The .nbRequestsPerMinPerSession property contains the maximum total number of requests that a session can receive in one minute.

Scope: session default level

.nbSessions​

nbSessions : Integer

Description​

The .nbSessions property contains the maximum total number of active sessions on the Web server.

Scope: server global level

.outBytesPerHour​

outBytesPerHour : Integer

Description​

The .outBytesPerHour property contains the maximum total number of bytes that the Web server can send in one hour. The quota is evaluated on the uncompressed response payload size, regardless of the Web server compression settings.

Scope: server global level

.outBytesPerHourPerSession​

outBytesPerHourPerSession : Integer

Description​

The .outBytesPerHourPerSession property contains the maximum total number of bytes that the Web server can send for a session in one hour. The quota is evaluated on the uncompressed response payload size, regardless of the Web server compression settings.

Scope: session default level

.outBytesPerMin​

outBytesPerMin : Integer

Description​

The .outBytesPerMin property contains the maximum total number of bytes that the Web server can send in one minute. The quota is evaluated on the uncompressed response payload size, regardless of the Web server compression settings.

Scope: server global level

.outBytesPerMinPerSession​

outBytesPerMinPerSession : Integer

Description​

The .outBytesPerMinPerSession property contains the maximum total number of bytes that the Web server can send for a session in one minute. The quota is evaluated on the uncompressed response payload size, regardless of the Web server compression settings.

Scope: session default level