经过这么长时间的网站死? [英] Site dies after so long?

查看:119
本文介绍了经过这么长时间的网站死?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站做一些事情,我以前从未见过。我的服务器是2003赢瓦特/ IIS6我使用C#和.NET 4.0。

该网站是一个房地产网站的数据直接在我的数据库存储。该网站将一小会儿运行很大,然后就死了。我的意思是,你会尝试查看酒店的详细信息,而且需要现场2-3分钟来加载,如果它加载在所有。如果我只是重新保存Web.config文件并重新上传它重新启动应用程序,它运行得很好了一会儿,然后将再次死去。这延续了一遍又一遍。我去了当地的副本,同时直播网站已经死了,并本地副本将运行得很好,然后它会经过这么长时间,以及死亡。它需要的时间框架为5分钟到30分钟而变化,相信它具有是与请求的数目

任何人有任何线索,以什么可能发生?唯一的页面上的数据的查询是拉主数据,低于LINQ查询:

 上市GetListingByMLNumber(字符串MLNumber)
{
    尝试
    {
        DatabaseDataContext DB =新DatabaseDataContext();
        在db.Listings变种项=(从
                    其中,a.ML_.ToLower()== MLNumber.ToLower()
                    选择一个).FirstOrDefault();        归还物品;
    }
    赶上(异常前)
    {
        消息= ex.Message;
        返回null;
    }
}


解决方案

不关闭数据库情况下脱颖而出,在C您提供的$ C $明显的错误。它包装在一个使用语句,以确保它得到正确的处理。

只要上下文生活,你将举行一个SQL连接,这是一种有限的资源。您还可以通过更改跟踪你返回的实体浪费内存。鉴于你的code的背景下应该被垃圾收集在某些时候,但它可能仍然是问题(而且,这是否是问题,您应该释放你的数据库环境)。

本地

尝试负载测试,看看你是否能重现该问题。如果可以的话,那么使用调试器来找出问题。如果没有,你可能需要添加日志记录来缩小这个问题。

您也可以看看IIS进程,看看它使用的内存量的荒唐,拉手等,同时检查是否存在性能和应用程序池循环的竞争IIS设置在这里另一个答案建议。

I have a website doing some things that I've never seen before. My server is Win 2003 w/ IIS6 I'm using C# and .Net 4.0.

The site is a real-estate website that stores the data directly in my db. The site will run great for a little while and then just die. What I mean is you'll try to view a property's details and it will take the site 2-3 minutes to load, if it loads at all. If I simply resave the web.config file and reupload it to restart the app, it runs just fine for a little while and then will die again. This continues over and over. I've gone to the local copy while the live site has "died" and the local copy will run just fine and then it will die after so long as well. The time frame that it takes varies from 5 minutes to 30 minutes, i believe it has something to do with the number of requests.

Anyone have any clue as to what might be happening? The only the data query on the page is to pull the main data which is the LINQ query below:

public Listing GetListingByMLNumber(string MLNumber)
{
    try
    {
        DatabaseDataContext db = new DatabaseDataContext();
        var item = (from a in db.Listings
                    where a.ML_.ToLower() == MLNumber.ToLower()
                    select a).FirstOrDefault();

        return item;
    }
    catch (Exception ex)
    {
        Message = ex.Message;
        return null;
    }
}

解决方案

Not closing the database context stands out as the obvious error in the code you provided. Wrap it in a using statement to be sure it gets disposed correctly.

As long as the context lives, you will hold on to a sql connection, which is a limited resource. You will also waste memory by change-tracking the entities you returned. Given your code the context should be garbage collected at some point, but it might still be the problem (And, whether or not this is the problem, you should dispose your database contexts).

Try load testing locally to see if you can reproduce the problem. If you can, then use the debugger to figure out the problem. If not, you probably need to add logging to narrow down the problem.

You could also look at the IIS process to see if it uses absurd amounts of memory, handles, etc. Also check IIS settings for performance and application pool recyling as suggested in another answer here.

这篇关于经过这么长时间的网站死?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆