Search code examples
asp.netbandwidthmulti-tenant

Bandwidth Monitoring in asp.net


Hi, We are developing a multi-tenant application in Asp.Net with separate Database for each tenant, in which one of the requirement is to monitor the bandwidth usage for each tenant,

i have tried to search but not found much help on the topic,we want to monitor exactly how much bandwidth is being used for each tenant while each tenant can have its own top level domain or a sub domain or a combination of both.

so what are the available options, the ones which i can think of can be

  1. IIS Log Monitoring means a separate application which will calculate the bandwidth for each tenant.
  2. Log Each Request and Response for a tenant from within the application and then calculate the total bandwidth usage based on that.
  3. Use some third part components if available

So what do you think will be the best approach, also if there is any other way to do this.


Solution

  • Ok, here is an idea (that I have not test, leave that to you)

    On global.asax use one of this function (find the one that have a valid final size)

    Application_PostRequestHandlerExecute
    Application_ReleaseRequestState
    

    and get the size that you have send with

    Response.Filter.Length
    

    No need to metion, that you get the filename of the call using the

    HttpContext.Current.Request.Path
    

    This functions called with every single request, so you can get your size and you do the rest.

    Here must note, that you need first to test this idea to see if its work, and maybe improve it, and have in mine that if you have compress the pages on server the length is not the correct and maybe you need to compress it on Global.asax to have the actually lenght.

    Hope this help.