Handling large web based processes

I am working on a new function for a ASP.NET MVC website. The execution time is quite long at present so I am considering options.

The function takes an excel spreadsheet, uploads it to the web server. It then needs to select all of the rows and using Entity Framework insert the rows in to a database. Each row matches the required entity model. Currently at only 50000 rows, this process takes a while and I would assume the row count will grow in the future.

I have a few options for processing here and I am wondering if there is a better way to handle it. The two ideas I have just now are

1) Pass the work off to a service, which on completion emails the user. The obvious upside being the user doesn’t need to keep that browser window open.
2) Add a progress bar and have the service pass updates back to jquery/javacript to do visual updates.

I will attempt to reduce the time, possibly moving the queries away from relying on Entity Framework. Sometimes stored procedures are a lot faster than Linq To Entities but with that aside, the process may still take more than a few seconds, which I don’t really want to burden the user with.

Can anyone think of other/better ways to handle long running processes on a web application? Are there any best practice schools of thought on handling these situations?

5

Doing the background service or task is correct tactic here — web servers really are meant to serve brief requests not long running tasks. Best to keep those off the server. You also get the added advantage of making things like bulk processing easier to achieve as it is sitting there waiting to do it’s thing.

If it needs to be synchronous some sort of progress bar is in order. Another option would be a simple status panel and notification options, especially if things start taking longer once you have real traffic.

1

You definitely need to go async at some point, however it’s quite complex and I’d avoid doing it until you really have the problem.

There are a few different approaches but your webserver should do as little as possible. The simplest way to handle this is to let it handle the upload and put the file in a folder.

There are different approaches here but another worker process will need to take the file and process it (btw, entity framework might not be your best option for this kind of heavy lifting). To spin off the other process you can typically do one of these things

  • As you mentioned, you can invoke a separate service asynchronously.
  • Have a scheduled service scour the destination directory looking for new files. This is good because this can be run on a completely different server from the web server if needs be, however for the same reason it’s very hard, to give real time progress reports to the user. Also, you induce a latency (e.g. if you scan the folder every 5 minutes, the user might have to wait for that long at least).
  • Have a the response thread spin off a background thread. Pro, it’s fairly easy to get progress and push it to the browser, but con, you are using the web server to do non-web stuff, unless you are careful this won’t scale as well as you would imagine.
  • Post a message to a message queue that dispatches it to the background worker. This makes it possible to have 2 way communication, but it’s probably the most complex solution of the three (because it has many moving parts).

I would generally advise you to use the simplest possible solution that would work and only use a more complex one if you are forced by circumstance. These kind of things tend to become devilishly complex and hard-to-debug really quickly.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật