ASP.NET 长任务挂起其他页面?
我正在使用出色的 SpreadSheetGear 工具即时生成报告。起初一切都很棒,因为报告很简单并且在一秒之内就完成了。现在我正在处理更复杂的报告,它们需要大约 30 秒到 1 分钟的时间。这不是问题,我们只是抛出一个活动图像并让用户等待,我们没问题。
我发现的问题是当两个用户访问该网站时。
- 用户 1 来到站点
- 用户 1 运行一份报告需要 30 秒。
- 用户 2 访问该站点
- 用户 2 等待用户 1 报告完成,然后加载页面。
为用户 1 运行的报告会挂起站点,直至完成。这是怎么回事?我该如何解决这个问题?
I'm generating reports on the fly using the great SpreadSheetGear tool. At first things were great because the reports were simple and done in under 1 second. Now I'm at more complex reports and they are taking about 30 seconds up to 1 minute. This isn't a problem, we just throw up an activity image and let the user wait, fine by us.
The problem I've found is when two users come to the site.
- User 1 comes to the site
- User 1 runs a report that takes 30 seconds.
- User 2 comes to the site
- User 2 waits until user 1 report is done then the page loads.
The report running for User 1 hangs up the site until it's done. What is going on and how can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
报告数据多久更改一次?例如,如果您使用的是 SQL Server,则可以使用存储过程来将报告数据创建到表中,并将该存储过程作为 SQL Server 代理作业运行。将作业设置为根据您想要更新的数据频繁运行。这应该会大大加快您的页面速度。
听起来您可能在同一个线程上有两个请求?
How often does the report data change? If for example you were using SQL Server, you could have a stored procedure to create the report data to a table and have the stored procedure run as a SQL Server Agent job. Set the job to run a frequently as you want the data updated. This should speed up your pages considerably.
Sounds like you may have both requests on the same thread?
您没有分享有关代码外观的任何详细信息,但听起来您应该考虑制作 异步页面。简而言之,技巧是将繁重的工作从线程池中移出,线程池用于服务页面请求。通过将繁重的工作转移到其他线程,线程池线程可以快速返回到池中,以便为其他传入请求提供服务。
那么更重要的是生成报告的机器可以承担多少工作。
You don't share any details on what the code looks like, but it sounds like you should look into making asynchronous pages. In short the trick is to move heavy work off the threads from the thread pool, which is used to serve page requests. By moving the heavy work to other threads, the thread pool thread can be returned to the pool quickly in order to serve other incoming requests.
Then it's more a matter of how much work the machine producing the reports can take.