每天第一次调用网络服务很慢

发布于 2024-07-25 08:47:53 字数 132 浏览 3 评论 0原文

在构建此 Web 服务和调用它的应用程序时,我们注意到每天对该 Web 服务的第一次调用非常慢。 有时甚至会超时。 然而,此后的每一次通话都效果很好。 有人能解释一下为什么会这样以及我们如何摆脱这种痛苦吗?

提前致谢!

While building this web service and the app that calls it, we have noticed that the first call to the web service each day is extremely slow. It even will time out on some days. However, every call after that work great. Can anybody shed light on why this might be and how we can get rid of this pain?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

二智少女猫性小仙女 2024-08-01 08:47:53

如果是 ASP.NET Web 服务,则可能是 CLR 首次初始化、加载和验证程序集。 您可能需要考虑预编译

If it's an ASP.NET web service, it may be the CLR initializing and loading and verifying the assemblies for the first time. You may want to consider pre-compilation

十二 2024-08-01 08:47:53

同意关于缓存、初始化等的其他答案。就解决方法而言,一种可能是设置某种日常任务(SQL Server 作业、Windows 服务,还是其他东西?)来模拟每个服务的命中一天,这样您的用户就不会遇到第一个缓慢的请求。

Agree with the other answers on caching, initialization, etc. As far as a workaround, one possibility may be to set up some sort of daily task (SQL Server job, Windows service, something else?) to simulate a hit to the service each day, so that your users don't experience this first slow request.

梦在深巷 2024-08-01 08:47:53

如果它是 ASP.NET Web 服务,那么您可能需要检查该 Web 服务运行所在的应用程序池的设置,尤其是空闲超时,在 IIS7 中默认为 20 分钟。

配置 IIS7 空闲超时

即使是不是 ASP.NET Web 服务,其他 Web 服务器将具有等效的配置设置,您必须进行调整才能使您的 Web 服务保持夜间运行。

If it is an ASP.NET web service, then you might want to check the settings of the application pool the web service is running in, especially the idle timeout which defaults to 20 minutes in IIS7.

Configuring IIS7 idle-timeout

Even if it is not an ASP.NET web service, other web servers will have equivalent configuration settings you have to tweak to keep your web service alive overnight.

兰花执着 2024-08-01 08:47:53

您可以在数据库上复制相同的行为吗? 它可能只是数据库需要优化第一次运行的查询(也许参数是今天的日期?)。

Can you duplicate the same behavior on your database? It could just be the db needing to optimise the query for the first run (Maybe the parameter is today's date?).

听风念你 2024-08-01 08:47:53

Global.asax 类中是否有很多静态构造函数或设置代码? 由于 IIS 会定期回收工作进程,因此启动代码可能会再次运行。

Are there a lot of static constructors or set up code in the Global.asax class? Because IIS recycles worker processes periodically, the start up code may be running again.

ㄟ。诗瑗 2024-08-01 08:47:53

优化的规则是:不要猜测。 进行分析以准确找出缓慢的原因,然后努力使其更快。 已经发布的所有内容都提供了关于从哪里开始寻找缓慢问题的绝佳提示。

The rule for optimization is: don't guess. Put in profiling to find out exactly what is slow, and then work to make that faster. Everything already posted provides excellent tips on where to start looking for slowness.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文