简体   繁体   中英

.asmx service : what is best way to call a method upto 300 times from inside web method?

I have one existing web method (built in .net 4.0 asmx) which is making call to two different databases to fetch the data and after processing data , it is returning a key to client as string. Existing functionality is such that it is fetching data from one table and generating a key and checking this in another database and if it is not in second database then it returns the key to client of web service.

Now we have got a change request where we have to update the web method which can generate up to 300 keys. And in this we might need to call those databases 300 times, which may hit the performance..

Please suggest what would be the best way to implement this?? Threading ?? or anything else??

Constraints : Service is hosted in iis Built in .net 4.0 Using .asmx template

[WebMethod]
public string GetKey(string parameter) 

    {
        /// Fetches data from  database 1 
        /// Fetches data from database 2
        /// Based on some calculation returns Key1

        returns key1;

    }

above is existing logic now to get 300 different keys , I may need to call the above Web Method up to 300 times from client which would be a bigger performance issue

or I may need to implement thread inside the Web Method but then there may be again performance issue due to worker thread of IIS.

Please suggest how should I implement the Web Method so that it can minimum performance impact for generating up to 300 keys.

Thanks in advance

Just call database once and pass there all 300 keys. something like this:

SELECT Key FROM Table
WHERE Key IN (array of keys)

then in answer you got all already existing keys. And can to regenerate them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM