QuotaManager
La clase 4D.QuotaManager le ofrece una interfaz para configurar y monitorizar algunos límites de uso que aplica a su aplicación 4D. Los umbrales son útiles, por ejemplo, para proteger el servidor frente a solicitudes mal optimizadas o del uso excesivo de los recursos del servidor. Para el servidor REST, por ejemplo, las cuotas pueden limitar los recursos ORDA accesibles para una sesión REST.
Los objetos 4D.QuotaManager se pueden instanciar de las siguientes maneras:
- la propiedad
quotasde un objeto Session - la propiedad
quotasde un servidor web
Para obtener más información sobre la configuración y la aplicación de cuotas en el servidor web, consulte Cuotas del servidor web.
Historia
| Lanzamiento | Modificaciones |
|---|---|
| 21 R5 | Soporte de cuotas en el servidor Web |
| 21 R4 | Clase añadida |
Objeto QuotaManager
Por defecto, las propiedades de un objeto 4D.QuotaManager son Undefined, lo que significa que no se aplica ninguna cuota correspondiente.
El objeto 4D.QuotaManager no se puede asignar directamente, ni se le pueden añadir ni eliminar propiedades. Las cuotas se configuran modificando las propiedades correspondientes del objeto existente.
Los objetos 4D.QuotaManager ofrecen las siguientes propiedades:
| currentValues : Object current usage values for the quota manager |
| defaultEntitySetTimeout : Integer el tiempo de espera predeterminado por inactividad para los conjuntos de entidades REST almacenados en memoria durante la sesión actual (en segundos) |
| 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 el valor máximo del tiempo de espera por inactividad para los conjuntos de entidades REST almacenados en memoria durante la sesión actual (en segundos) |
| nbEntitySets : Integer el número máximo de conjuntos de entidades REST permitidos en memoria para la sesión actual |
| 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
Descripción
The .currentValues property contains current usage values for the quota manager. 4D lo actualiza automáticamente y es de solo lectura.
El objeto tiene las mismas propiedades que el objeto 4D.QuotaManager, pero solo las siguientes propiedades indican el uso actual:
.defaultEntitySetTimeout
defaultEntitySetTimeout : Integer
Descripción
Esta cuota solo se puede configurar para la sesión REST actual a través de Session.quotas.
La propiedad .defaultEntitySetTimeout contiene el tiempo de espera predeterminado por inactividad para los conjuntos de entidades REST almacenados en memoria durante la sesión actual (en segundos).
Alcance: sesión actual
Por defecto, este valor es de 2 horas (7200 segundos). También se puede definir al crear el conjunto de entidades mediante la API REST $timeout.
Puede modificar este valor de forma dinámica mediante la propiedad quotas.defaultEntitySetTimeout de la sesión, de modo que se aplique a cualquier conjunto de entidades que se cree posteriormente en la sesión (los valores de tiempo de espera predeterminados de los conjuntos de entidades existentes no se modifican).
Si se define un valor superior al de la propiedad maxEntitySetTimeout, dicho valor se ajustará al de maxEntitySetTimeout.
No se puede pasar un valor <=0 (en ese caso se produce un error). Para restablecer el valor de la propiedad para la sesión, pase undefined.
Ejemplo
En un código 4D de un proceso REST:
Session.quotas.defaultEntitySetTimeout:=1200
.inBytesPerHour
inBytesPerHour : Integer
Descripción
The .inBytesPerHour property contains the maximum total number of bytes that the Web server can receive in one hour.
Alcance: servidor global
.inBytesPerHourPerSession
inBytesPerHourPerSession : Integer
Descripción
The .inBytesPerHourPerSession property contains the maximum total number of bytes that the Web server can receive for a session in one hour.
Alcance: sesión por defecto
.inBytesPerMin
inBytesPerMin : Integer
Descripción
The .inBytesPerMin property contains the maximum total number of bytes that the Web server can receive in one minute.
Alcance: servidor global
.inBytesPerMinPerSession
inBytesPerMinPerSession : Integer
Descripción
The .inBytesPerMinPerSession property contains the maximum total number of bytes that the Web server can receive for a session in one minute.
Alcance: sesión por defecto
.maxEntitySetTimeout
maxEntitySetTimeout : Integer
Descripción
Esta cuota solo se puede configurar para la sesión REST actual a través de Session.quotas.
La propiedad .maxEntitySetTimeout contiene el valor máximo del tiempo de espera por inactividad para los conjuntos de entidades REST almacenados en memoria durante la sesión actual (en segundos).
Alcance: sesión actual
Puede definir este valor utilizando la propiedad quotas.maxEntitySetTimeout de la Sesión, para que se utilice para cualquier conjunto de entidades creado después en la sesión (los valores máximos de tiempo de espera de los conjuntos de entidades existentes no se modifican).
Una vez configurada la propiedad .maxEntitySetTimeout, ningún conjunto de entidades creado posteriormente en la sesión podrá tener un tiempo de espera superior al valor de .maxEntitySetTimeout.
Por ejemplo, supongamos que el tiempo de espera por inactividad máximo está fijado en 40 minutos (2400 segundos); si se crea un conjunto de entidades con un tiempo de espera obligatorio que supera el valor máximo:
http://127.0.0.1/rest/People?$filter=ID>=4&$method=entityset&$timeout=3000
... entonces el tiempo de espera definido en la solicitud es ignorado y el conjunto de entidades será liberado después de 40 minutos si no se utiliza durante este período de tiempo.
No se puede pasar un valor <=0 (en ese caso se produce un error). Para restablecer el valor de la propiedad para la sesión, pase undefined.
Ejemplo
En un código 4D de un proceso REST:
Session.quotas.maxEntitySetTimeout:=2400
.nbEntitySets
nbEntitySets : Integer
Descripción
Esta cuota solo se puede configurar para la sesión REST actual a través de Session.quotas.
La propiedad .nbEntitySets contiene el número máximo de conjuntos de entidades REST permitidos en memoria para la sesión actual.
Alcance: sesión actual
Por defecto, no hay límite para conjuntos de entidades almacenados en memoria por solicitudes REST (el valor es 0). Puede definir un límite para controlar la carga útil del servidor para una sesión específica.
Cuando se alcanza el número máximo de conjuntos de entidades permitidas, una solicitud REST que necesita crear un entity set obtendrá un status code HTTP 429 y una respuesta de error, hasta que al menos un entity set sea liberado. Puede liberar un conjunto de entidades de la caché mediante el comando $release REST.
No se puede pasar un valor <=0 (en ese caso se produce un error). Para restablecer el valor de la propiedad para la sesión, pase undefined.
Ejemplo
En un código 4D de un proceso REST:
//máximo 50 conjuntos de entidades
Session.quotas.nbEntitySets:=50
.nbEntitySetsPerSession
nbEntitySetsPerSession : Integer
Descripción
Esta cuota sólo se aplica a una sesión REST.
The .nbEntitySetsPerSession property contains the maximum number of entity sets allowed in memory for each REST session.
Alcance: sesión por defecto
.nbGuestSessions
nbGuestSessions : Integer
Descripción
The .nbGuestSessions property contains the maximum total number of active Guest sessions on the Web server.
Alcance: servidor global
.nbRequestsPerHour
nbRequestsPerHour : Integer
Descripción
The .nbRequestsPerHour property contains the maximum total number of requests that the Web server can receive in one hour.
Alcance: servidor global
.nbRequestsPerHourPerSession
nbRequestsPerHourPerSession : Integer
Descripción
The .nbRequestsPerHourPerSession property contains the maximum total number of requests that a session can receive in one hour.
Alcance: sesión por defecto
.nbRequestsPerMin
nbRequestsPerMin : Integer
Descripción
The .nbRequestsPerMin property contains the maximum total number of requests that the Web server can receive in one minute.
Alcance: servidor global
.nbRequestsPerMinPerSession
nbRequestsPerMinPerSession : Integer
Descripción
The .nbRequestsPerMinPerSession property contains the maximum total number of requests that a session can receive in one minute.
Alcance: sesión por defecto
.nbSessions
nbSessions : Integer
Descripción
The .nbSessions property contains the maximum total number of active sessions on the Web server.
Alcance: servidor global
.outBytesPerHour
outBytesPerHour : Integer
Descripción
The .outBytesPerHour property contains the maximum total number of bytes that the Web server can send in one hour. La cuota se calcula en función del tamaño de la carga útil de la respuesta sin comprimir, independientemente de la configuración de compresión del servidor web.
Alcance: servidor global
.outBytesPerHourPerSession
outBytesPerHourPerSession : Integer
Descripción
The .outBytesPerHourPerSession property contains the maximum total number of bytes that the Web server can send for a session in one hour. La cuota se calcula en función del tamaño de la carga útil de la respuesta sin comprimir, independientemente de la configuración de compresión del servidor web.
Alcance: sesión por defecto
.outBytesPerMin
outBytesPerMin : Integer
Descripción
The .outBytesPerMin property contains the maximum total number of bytes that the Web server can send in one minute. La cuota se calcula en función del tamaño de la carga útil de la respuesta sin comprimir, independientemente de la configuración de compresión del servidor web.
Alcance: servidor global
.outBytesPerMinPerSession
outBytesPerMinPerSession : Integer
Descripción
The .outBytesPerMinPerSession property contains the maximum total number of bytes that the Web server can send for a session in one minute. La cuota se calcula en función del tamaño de la carga útil de la respuesta sin comprimir, independientemente de la configuración de compresión del servidor web.
Alcance: sesión por defecto