jeudi 23 juillet 2015

Allowing only on web request to access in memory resource

I have to implement the following solution and I'm wondering what the best way would be to go about it. The concept is simple:

I have a collection of 25 excel spreadsheets for separate lenders. They are maintained by lenders who provide credit/loans to applicants. These spreadsheets contains complex formulas that determine if a loan application will be considered by a lender or not. I'm using NPOI to input data into the required cells, and then read the calculated output from the spreadsheet. The it takes about 4 seconds to load all 25 sheets into memory, it would be best to rather load everything into memory at application startup, and then process application requests as they come in.

The class library that im developing will sit behind a WebAPI 2.0 service, and process requests as they come in. Because there will be only once collection of all spreadsheets in memory, I'm only going to process on request at a time. It takes about 200ms to go through all 25 sheets and read the outcome, so its pretty fast. Having some sort of message queue or "producer, consumer" pattern to process all messages is what im looking for.

What would be the best way to implement this? Obviously I can use simple threading and a worker process that processes each thread, but I was wondering if there are a better approach to this?

Thanks

Aucun commentaire:

Enregistrer un commentaire