Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle multiple request in webapi method which internally access a database

We are serving multiple clients request using webapi, which is hosted on iis server.

How will the iis handle thousands of request, from clients?

1) How can we achieve best performance in this scenario ? 2) Will making webapi method, async will make any difference? 3) What are the best practices, that we need to follow ?

Thanks in advance.

like image 642
Maity Avatar asked Feb 28 '26 06:02

Maity


1 Answers

How will the iis handle thousands of request, from clients?

It depends. Actually, even the limitation of IIS might not be your major concern, there are other things that might affect IIS performance, like for example the hardware.

How can we achieve best performance in this scenario ?

You can do many things, you can use queue system, there is no need to make the user wait for a heavy transaction or very complex logic in many scenario. If the request of the user involve many different complex tasks you can do the minimum and return to the user and the rest can be done in the background. You can use a queue system for such scenario.

Will making webapi method, async will make any difference?

No, because async means 'This method is allowed to work asynchronously' or 'This method is allowed to use await operator'. You should know how to use concurrency not just asynchronous programming. But using Tasks for heavy transaction like dealing with the database and awaiting these Tasks in async methods, Yes, this will help your server respond to more requests at the same time.

What are the best practices, that we need to follow

A good understanding of the concurrency will be very helpful. Also, it's not just about the WEB API everything might affect your web application performance from the Data Access layer, to the indexes in the RDBMS even the response might contribute. Like if your response is XML you may use JSON because it generates relatively less data than XML thus faster data exchange. Your question is very broad and it really depends. It is not just about IIS or the Web API or even the whole Web application, it depends.

like image 155
Mahmoud Avatar answered Mar 02 '26 20:03

Mahmoud