4

嗨,我们正在 Asp.Net 中开发一个多租户应用程序,每个租户都有单独的数据库,其中一个要求是监控每个租户的带宽使用情况,

我尝试搜索但没有找到关于该主题的太多帮助,我们希望准确监控每个租户使用了多少带宽,而每个租户可以拥有自己的顶级域或子域或两者的组合。

那么有哪些可用的选项,我能想到的可以是

  1. IIS 日志监控意味着一个单独的应用程序,它将计算每个租户的带宽。
  2. 从应用程序中记录租户的每个请求和响应,然后据此计算总带宽使用量。
  3. 如果可用,请使用一些第三方组件

那么你认为最好的方法是什么,如果还有其他方法可以做到这一点。

4

3 回答 3

6

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.

于 2010-03-30T07:25:22.967 回答
0

好吧,由于 IIS 日志已经包含请求大小和响应大小,因此开发一个小工具来解析它们并计算每天/每周/每月/无论如何的总数似乎并没有太大的麻烦。

于 2010-03-30T05:33:20.337 回答
0

根据我的经验,尝试根据主机划分流量很困难。相反,如果您为每个租户提供他们自己的应用程序 IP,您应该能够找到将基于 IP 监控带宽的程序。

附加信息 IIS 的结构是您有一个网站来为所有租户管理它们,并在登录时系统分叉到正确的数据库?如果是这样,这可能会在版本控制方面产生问题,因为所有租户的站点都必须具有完全相同的架构,并且在您更新应用程序时都需要同时更新,从而需要架构更改。

听起来像您可能拥有的另一种结构是每个租户都有自己的网站,如下所示:

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.

于 2010-03-30T05:37:59.687 回答