views:

204

answers:

3

HI, We are developing a multi-tenant application in Asp.Net with separate DB 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.

A: 

Well, since the IIS logs already contain the request size and response size, it doesn't seem like too much trouble to develop a small tool to parse them and calculate the total per day/week/month/whatever.

Dean Harding
@Dean Harding Do you know if this includes streaming data? WCF, and adaptive streaming?
MakerOfThings7
A: 

Trying to segment traffic based on host is difficult in my experience. Instead, if you give each tenant their own IP(s) for the applications you should be able to find programs that will monitor bandwidth based on IP.

ADDITION Is the structure of IIS that you have one website to rule them all for all tenants and on login the system forks to the proper database? If so, this may create problems with respect to versioning in that all tenant's sites will all have to have exactly the same schema and would all need to be updated simultaneously when you update the application such that a schema change is required.

Another structure, which sounds like what you may have, is that each tenant has their own website like so:

tenant1_site/appvirtualdir
tenant2_site/appvirtualdir
...

Where the appvirtualdir points to the same physical path for all tenant's sites. When all clients have the same application version, they are all using literally the same code. If you have this scenario and some sort of authentication, then you will need one IP per tenant anyway because of SSL. SSL will only bind to IP and port unlike non-SSL which will bind to IP, port and host. If that were the case, then monitoring traffic based on IP will still be simpler and more accurate as it could be done at the router or via a network monitor.

Thomas
Actually assigning each tenant a separate ip is not a possible solution, as there is too many IPs required and also as the model is a single application multi DB so i think that it will not be a feasible solution.
asifch
I'm working with and have built just such a system. Whether you use a single database or multiple databases really is not the issue is it? What matters is the traffic to the webserver. Getting a C block or more shouldn't be an issue with your hosting provider. However, if you have a single website on the webserver and the tenants are segmented by folder, that is entirely different. In that scenario, you are compelled to parse the IIS logs.
Thomas
+4  A: 

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.

Aristos