【问题标题】:Ninject WebAPI.SelfHost Performance Issues under load (for a few seconds every few more seconds)Ninject WebAPI.SelfHost 负载下的性能问题(每隔几秒钟就会出现几秒钟)
【发布时间】:2013-03-05 20:40:01
【问题描述】:

我正在对我的 WebAPI 自托管应用程序进行一些负载测试,并发现 Ninject 的 Cache Pruning 会使应用程序停顿几秒钟(屏幕截图中的负载分析)。

如何避免缓存修剪停止请求??

我所做的只是设置 HttpSelfHostConfiguration.DependencyResolver = new NinjectDependencyResolver(new StandardKernel())(省略配置)

有没有办法在请求结束时删除对象?

更新:

从这里,https://github.com/ninject/ninject/issues/37,似乎期望在请求结束时删除对象只能用于 Ninject.Web 和 Ninject.Web.MVC

更新/注意:

我一直在使用 nuget 包 Ninject.Web.WebApi-RC 以及 AttributeRouting.WebApi.Hosted。

更新

我更新了范围和解析器定义,现在我发现我遇到了问题...我现在只是针对返回字符串常量的操作进行测试。

【问题讨论】:

    标签: c# performance asp.net-web-api ninject self-hosting


    【解决方案1】:

    使用https://nuget.org/packages/Ninject.Web.WebApi.Selfhost

    这是一个如何使用它的示例: https://github.com/ninject/Ninject.Web.WebApi/tree/master/src/Ninject.Web.WebApi.Selfhost

    它在请求结束时处理 InRequestScope 对象。

    【讨论】:

    • 谢谢你 - 这个 (github.com/remogloor/Ninject.Web.WebApi/tree/master/src/…) 是我刚刚看到的地方。这是 WebApi 特有的东西的主要动机,即处置对象吗?
    • 刚刚看到热路径是激活缓存。所以这可能不会解决这个问题。告诉我这个版本的最新情况。不移除对象不是主要动机。主要动机是在 MVC 和 WebAPI 中有相同的方式使用 Ninject
    • 我切换了软件包,并且正在关注您的示例自托管应用程序套件。但我目前“陷入”错误:找不到方法:'System.Web.Http.Services.DefaultServices System.Web.Http.HttpConfiguration.get_Services()'。不过还在挖……
    • 我在构建 StandardKernel() 时得到了以上信息,有什么想法吗?搜索指向过时的二进制文件?
    • 肯定卡住了:(在 Ninject.Web.WebApi.WebApiModule.Load() 在 Ninject.Modules.NinjectModule.OnLoad(IKernel kernel) 在 Ninject.KernelBase.Load(IEnumerable1 m) at Ninject.KernelBase.Load(IEnumerable1 程序集)在 Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable1 filenames) at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable1 patterns) 在 Ninject.KernelBase.Load(IEnumerable`1 filePatterns)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 1970-01-01
    • 1970-01-01
    • 2018-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多