2009-02-12 38 views
5

Tôi đang xem xét một ứng dụng asp.net mà làm cho các cuộc gọi đến một cơ sở dữ liệu trong ứng dụng bắt đầu bên trong global.asax. Các cuộc gọi này mất khoảng 3 giây (phụ thuộc vào gói bộ nhớ cache SQL) để chạy. Tôi đã nhận thấy rằng ứng dụng chạy từ từ khi tôi triển khai lại lần đầu tiên. Tôi đặt điều này xuống các cuộc gọi đến cơ sở dữ liệu trong khi ứng dụng bắt đầu. Tuy nhiên sau một vài phút, ứng dụng lại cần thời gian để tải.application_start bắn đột ngột asp.net

Để tìm hiểu điều gì sẽ xảy ra, tôi đã ghi vào tệp nhật ký (xem bên dưới). Từ tệp này, bạn có thể thấy rằng ứng dụng bắt đầu kích hoạt nhiều lần khi nhiều yêu cầu truy cập ứng dụng lần đầu tiên. Sau đó nó xuất hiện rằng application_start được kích hoạt một cách ngẫu nhiên (bất cứ thứ gì từ 2-10 phút).

Từ sự hiểu biết của tôi về cách thức hoạt động của application_starts, nó chỉ được kích hoạt khi ứng dụng FIRST bắt đầu, tuy nhiên nó dường như được kích hoạt ngẫu nhiên từ nhiều khách hàng! Theo MSDN "Sự kiện Application_Start được kích hoạt lần đầu tiên khi một ứng dụng khởi động."

Có ai có thể giúp tôi tìm hiểu điều gì đang xảy ra không? Tôi đang sử dụng IIS6 và .net 2.0. Nó là một thiết lập hồ bơi ứng dụng tôi đang mất tích.

Rất cám ơn Rippo

[12/02/2009 16:16:58] 91.84.25.241 - Application started, Sub MyRules started 
[12/02/2009 16:17:06] 65.55.51.34 - Application started, Sub MyRules started 
[12/02/2009 16:17:07] 91.84.25.241 - Application started, Sub MyRules completed 
[12/02/2009 16:17:10] 65.55.51.34 - Application started, Sub MyRules completed 
[12/02/2009 16:17:26] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:30] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:17:30] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:33] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:17:33] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:36] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:17:36] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:39] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:17:42] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:48] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:17:48] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:52] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:17:52] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:17:54] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:18:27] 91.84.25.241 - Application started, Sub MyRules started 
[12/02/2009 16:18:31] 91.84.25.241 - Application started, Sub MyRules completed 
[12/02/2009 16:18:31] 212.115.51.229 - Application started, Sub MyRules started 
[12/02/2009 16:18:33] 212.115.51.229 - Application started, Sub MyRules completed 
[12/02/2009 16:29:26] 167.230.38.115 - Application started, Sub MyRules started 
[12/02/2009 16:29:28] 167.230.38.115 - Application started, Sub MyRules completed 
[12/02/2009 16:29:34] 82.110.42.84 - Application started, Sub MyRules started 
[12/02/2009 16:29:37] 82.110.42.84 - Application started, Sub MyRules completed 
[12/02/2009 16:29:38] 82.110.42.84 - Application started, Sub MyRules started 
[12/02/2009 16:29:41] 82.110.42.84 - Application started, Sub MyRules completed 
[12/02/2009 16:32:53] 99.142.1.97 - Application started, Sub MyRules started 
[12/02/2009 16:32:57] 99.142.1.97 - Application started, Sub MyRules completed 
[12/02/2009 16:32:57] 99.142.1.97 - Application started, Sub MyRules started 
[12/02/2009 16:33:01] 99.142.1.97 - Application started, Sub MyRules completed 
[12/02/2009 16:33:01] 99.142.1.97 - Application started, Sub MyRules started 
[12/02/2009 16:33:06] 99.142.1.97 - Application started, Sub MyRules completed 
[12/02/2009 16:33:06] 99.142.1.97 - Application started, Sub MyRules started 
[12/02/2009 16:33:10] 99.142.1.97 - Application started, Sub MyRules completed 
[12/02/2009 16:33:11] 99.142.1.97 - Application started, Sub MyRules started 
[12/02/2009 16:33:16] 99.142.1.97 - Application started, Sub MyRules completed 
[12/02/2009 16:36:15] 65.55.51.34 - Application started, Sub MyRules started 
[12/02/2009 16:36:17] 65.55.51.34 - Application started, Sub MyRules completed 
[12/02/2009 16:41:37] 119.123.226.156 - Application started, Sub MyRules started 
[12/02/2009 16:41:37] 62.49.121.122 - Application started, Sub MyRules started 
[12/02/2009 16:41:40] 62.49.121.122 - Application started, Sub MyRules completed 
[12/02/2009 16:41:40] 119.123.226.156 - Application started, Sub MyRules completed 
[12/02/2009 16:41:41] 62.49.121.122 - Application started, Sub MyRules started 
[12/02/2009 16:41:44] 62.49.121.122 - Application started, Sub MyRules completed 
[12/02/2009 16:45:17] 84.70.249.242 - Application started, Sub MyRules started 
[12/02/2009 16:45:19] 84.70.249.242 - Application started, Sub MyRules completed 
[12/02/2009 16:47:03] 80.41.121.68 - Application started, Sub MyRules started 
[12/02/2009 16:47:05] 80.41.121.68 - Application started, Sub MyRules completed 
[12/02/2009 16:47:29] 81.179.26.249 - Application started, Sub MyRules started 
[12/02/2009 16:47:31] 81.179.26.249 - Application started, Sub MyRules completed 
[12/02/2009 16:47:59] 81.136.179.170 - Application started, Sub MyRules started 
[12/02/2009 16:47:59] 81.136.179.170 - Application started, Sub MyRules started 
[12/02/2009 16:48:02] 81.136.179.170 - Application started, Sub MyRules completed 
[12/02/2009 16:48:02] 81.136.179.170 - Application started, Sub MyRules started 
[12/02/2009 16:48:02] 81.136.179.170 - Application started, Sub MyRules completed 
[12/02/2009 16:48:02] 81.136.179.170 - Application started, Sub MyRules started 
[12/02/2009 16:48:04] 81.136.179.170 - Application started, Sub MyRules completed 
[12/02/2009 16:48:04] 81.136.179.170 - Application started, Sub MyRules completed 
[12/02/2009 16:52:35] 69.34.161.80 - Application started, Sub MyRules started 
[12/02/2009 16:52:35] 69.34.161.80 - Application started, Sub MyRules started 
[12/02/2009 16:52:35] 69.34.161.80 - Application started, Sub MyRules started 
[12/02/2009 16:52:38] 69.34.161.80 - Application started, Sub MyRules completed 
[12/02/2009 16:52:38] 69.34.161.80 - Application started, Sub MyRules started 
[12/02/2009 16:52:39] 69.34.161.80 - Application started, Sub MyRules completed 
[12/02/2009 16:52:39] 69.34.161.80 - Application started, Sub MyRules completed 
[12/02/2009 16:52:40] 69.34.161.80 - Application started, Sub MyRules completed 

Trả lời

0

Nó bật ra được một dll bị rò rỉ ...

+0

dll bị rò rỉ Tôi tự hỏi ... –

+0

Sau 5 năm nó có một rò rỉ lớn bây giờ ... nghiêm trọng mặc dù, nếu bộ nhớ phục vụ tôi phải nó là một bên thứ 3 viết lại dll có một lỗi trong đó và đã ném lỗi gây ra ứng dụng để tái chế liên tục ... không thể nhớ chi tiết – Rippo

+0

lỗi bên thứ ba đó là! =) –

2

Kiểm tra bản ghi sự kiện, một cái gì đó đang gây ra các hồ bơi ứng dụng để tái chế.

15

Kiểm tra xem ứng dụng khởi động lại những trường hợp nào. Gần đây, chúng tôi đã viết một số mục nhập nhật ký vào thư mục bin và chính xác điều tương tự đã xảy ra và chúng tôi không hiểu lý do. Sau đó cuối cùng nhận ra rằng thực hiện bất kỳ sửa đổi nào đối với thư mục bin đã khiến ứng dụng khởi động lại.

+0

Tôi đã làm điều này và vật lộn với ứng dụng web của mình trong vài giờ qua. Cảm ơn câu trả lời ở đây, mặc dù nó không chính xác những gì đã xảy ra liên quan đến câu hỏi này! –

+0

+1 - Tôi đã bán phá giá một tệp SQL đã tạo ở đó và không biết tại sao ứng dụng đã khởi động lại. Tôi sẽ bỏ phiếu 1000 lần nếu tôi có thể. – TheCloudlessSky

+0

Cảm ơn bạn đã lưu chuyến đi dài! – kalki

2

Tôi đã có một vấn đề với các Application_Start nhận được gọi là nhiều lần, và nó quay ra đó là vì tôi đã có nhiều trường hợp thiết lập. Sai lầm ngu ngốc, nhưng tôi muốn lưu ý nó.

1

Tôi không biết tại sao, nhưng tôi thấy điều tương tự trong nhật ký của mình. Có phải vì nó mất quá nhiều thời gian và bạn có nhiều yêu cầu đến cùng lúc không? Dù sao, chỉ để an toàn, tôi đang thêm mã này:

public class MvcApplication : HttpApplication 
{ 
    private static volatile bool hasRegisteredBgTasks = false; 
    private static object registeredBgTasksLock = new object(); 

    protected void Application_Start() 
    { 
     lock (registeredBgTasksLock) 
     { 
      if (hasRegisteredBgTasks) 
      { 
       return; 
      } 
      // Actual start up code. 
      hasRegisteredBgTasks = true; 
     } 
    } 

    // Other Application methods... 
} 
+0

Một khả năng khác trong trường hợp của tôi là sử dụng triển khai web đến trang web trực tiếp. Tôi có thể đã được triển khai một nửa, người dùng truy cập nó, khởi động ứng dụng, sau đó nhiều tệp khác xuất hiện và khởi động lại. –

Các vấn đề liên quan