Reputation: 681
I have a web application that has a long running (resource intensive) process in the code behind and the end output is a pdf file (images to pdf conversion tool)
It runs fine..and since I am on a dedicated server, it is not at all a problem with respect to resources right now.
However, I wonder that the system would reach its resource limits if, there are more than 20 users processing at a time.
I have seen services online where the user enters their email and the processes are, I suppose, queued in the background and the results emailed with the 1st in 1st out method.
Can someone please give me a start on how to implement this kind of logic in asp.net applications using C#?
Upvotes: 3
Views: 1924
Reputation: 311
You need some workers to process your task in the background and send results. Due to @Klaus answer, I suggest using Hangfire. We use it for creating a background job inside our ASP app and doing a long-running process (ex: request for image processing).
Upvotes: 0
Reputation: 1
As Klaus rightly pointed out, we've to implement it using windows services
Addendum to his answer:
(i)Split the long running process into multiple tasks
(ii)For each task , create a separate console application & identity each app using applicationId.
enum ApplicationId:byte
{
Router = 1,
Task1 = 2,
Task2 = 3,
Task3 = 4,
Task4 = 5,
Email = 6
}
(iii)Call one application as Router. It'll move transactions from one application to another.
(iv)Now create a table with transactionId, nextAppId and any other relevant fields
(v)After completing the task, update the nextAppId in table
(vi)Schedule all the apps in windows task scheduler or use active batch server (commercially)
(vii)The last application 'Email' sends an e-mail with generated pdf as an attachment to the user
Hope this answers !!!!. Have a nice day!!!
Upvotes: 0
Reputation: 115488
You want to throttle the number of concurrent requests. You can create a separate application to handle the conversion process. Either a windows service or a scheduled task that runs at a regular interval.
The great part about having an external program handle the conversion is that you can load the program on multiple machines to process the requests faster, and it/they don't have to slow down your web/app servers used to handle the website.
Upvotes: 0
Reputation: 120937
Such a system would consist of a windows service running on the server. The only thing the asp.net page does is to submit a request (with the relevant data) to the database. The windows service then monitors this table and processes all new requests.
Upvotes: 5