앱 풀은 메모리 제한을 존중하지 않습니다 풀을 조정하는 방법을

메모리 누수가있는 레거시 .NET 앱을 다루고 있습니다. 런 어웨이 메모리 상황을 시도하고 완화하기 위해 500KB에서 500000KB (500MB) 사이의 앱 풀 메모리 제한을 설정했지만 앱 풀은 로그인하여 물리적으로 볼 수 있으므로 설정을 존중하지 않는 것 같습니다 메모리 (5GB 이상) 이 응용 프로그램은 서버를 죽이고 있으며 응용 프로그램 풀을 조정하는 방법을 결정할 수 없습니다. 이 앱 풀이 약 500MB의 메모리를 초과하지 않도록하기 위해 권장하는 설정

다음은 앱 풀이 3.5GB의

프로세스리스트

따라서 서버가 다시 충돌했고 다음과 같은 이유가 있습니다.

메모리 제한이 낮은 동일한 앱 풀, 1000 회 재순환 요청으로 2 ~ 3 분마다 재순환 이벤트가 발생하지만 때때로 실행됩니다.

또한이 프로세스를 모니터링 할 수있는 도구 (작업 또는 서비스로 30 초마다 실행)가 있으며 일부 제한을 초과하면 프로세스를 종료 할 수 있습니다.



답변

한계가 제한되지 않는 비슷한 것에 대답하기 위해 고심하고 있기 때문에이 게시물을 찾았습니다. IIS WebLimits가 존중되지 않음을 참조하십시오 .

그러나 나는 당신의 문제에 찌를 수 있습니다. 아래의 C # 코드를 사용해보십시오. powershell을 사용하여 동일한 작업을 수행 할 수 있습니다. 관리자 권한으로 실행해야합니다.

 static void Main(string[] args)
    {

        string appPoolName = args[0];
        int memLimitMegs = Int32.Parse(args[1]);
        var regex = new System.Text.RegularExpressions.Regex(".*w3wp.exe \\-ap \"(.*?)\".*");

        //find w3wp procs....
        foreach (var p in Process.GetProcessesByName("w3wp"))
        {

            string thisAppPoolName = null;

            try
            {
                //Have to use WMI objects to get the command line params...
                using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + p.Id))
                {
                    StringBuilder commandLine = new StringBuilder();
                    foreach (ManagementObject @object in searcher.Get())
                    {
                        commandLine.Append(@object["CommandLine"] + " ");
                    }

                    //extract the app pool name from those.
                    var r = regex.Match(commandLine.ToString());
                    if (r.Success)
                    {
                        thisAppPoolName = r.Groups[1].Value;
                    }

                    if (thisAppPoolName == appPoolName)
                    {
                        //Found the one we're looking for.
                        if (p.PrivateMemorySize64 > memLimitMegs*1024*1024)
                        {

                            //it exceeds limit, recycle it using appcmd.

                            Process.Start(Path.Combine(System.Environment.SystemDirectory , "inetsrv", "appcmd.exe"), "recycle apppool /apppool.name:" + appPoolName);

                            Console.WriteLine("Recycled:" + appPoolName);
                        }
                    }
                }
            }
            catch (Win32Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }