Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[hono-dev] [Hono #927 & #929] Limit number of connections and messages based on data volume for a tenant

Hi all,

 

I would like to talk about the below two issues, share an implementation proposal and hear your views on it.

 

#927 -  Limit the number of simultaneously connected devices. (Example: Tenant A can has a connection plan of 10000 simultaneously connected devices).

#929 - The data volume over a period should not exceed the configured value per tenant. (Example: Tenant A has a data usage plan of 2 GB per month).

 

In the above cases, protocol adapters must ensure that the number of simultaneously connected devices and the data volume (used over a period) for a tenant don't exceed the configured limits. In a real world scenario, apart from the number of connections and the data volume, more plans based on other factors are also possible such as limiting the number of messages per tenant for a time period. FMPOV it is basically connection and message plans for a tenant.

 

I can imagine very well the below two methods, which can be used by the Protocol adapters to check the plans before accepting a connection or a message. I think device registry (TenantObject) might be a suitable central place to hold these two methods.

 

Users with their own implementation of device registry can have their own implementation of these methods. I would like to start with #927 by providing a reference implementation with the default device registry shipped with Hono. As part of this, I would like to make the limits configurable by adding a parameter “connections-limit" to the tenant configuration. Inside method  “checkWithConnectionPlan(tenanId)”, connections related metrics data from Prometheus Backend will be used to validate the connections limit and the result is returned. Followed by changes in Protocol adapters to use this method to check the connections limit before accepting a connection.

 

    /**

     * Checks with the connection plan before accepting a new connection for a given tenantId

     * @param tenantId The tenant for which the object is constructed.

     * @returns if a new device connection is allowed or not.

     */

    public static boolean checkWithConnectionPlan(final String tenantId);

 

    /**

     * Checks with the message plan before accepting a message for a given tenantId

     * @param tenantId The tenant for which the object is constructed.

     * @returns if a message can be accepted or not.

     */

   public static boolean checkWithMessagePlan(final String tenantId);

 

WDYT?

 

Best Regards

Karthees




Back to the top