1

I have created simple ASP.NET Web API(self-host OWIN) which has endpoint http://MyIp:80/process/file. It can accept only five simultaneous requests and takes about 30 seconds to proceed it, if requests number exceeded the Rest Api brings HTTP exception. To increase number of requests I am planning to host the ASP.NET Web API application on another server but in that case I will get different IP address for Rest Api. I know that there are load balancing solutions but can't find good source how to use it with ASP.NET Web API. Any advise would be appreciated!

Tomas
  • 17,551
  • 43
  • 152
  • 257
  • 2
    That's because load balancing is a networking subject, it has nothing to do with Web API or any other framework. The load balancer exposes one public IP to the world but distributes traffic to multiple private IPs. It's the balancer's job to tralnslate between the different IPs – Panagiotis Kanavos Nov 04 '15 at 14:28
  • Is your problem that you already gave out your IP address to your consumers, and now want to relocate your service? You should've used DNS then... – CodeCaster Nov 04 '15 at 14:39

2 Answers2

0

The easiest way for you would be to use cloud. Especially for Microsoft technologies I would recommend Microsoft Azure. You will get scaling and load balancing out of the box as well as a lot of other benefits of using cloud.

Andrei
  • 42,814
  • 35
  • 154
  • 218
0

This is a poor man's load balancing... bear with me.

You can declare one server as primary and the second one as secondary.

If a request hits the primary, but it is already with those 5 requests processing, it can issue a HTTP 307 Temporary Redirect to the secondary one. If the secondary is also overloaded, then throw an error.

Using a 307 temporary redirection, the caller knows that can retry the same HTTP verb to the new location. So if the caller was doing a POST call to the primary, and gets a HTTP 307 pointing to the secondary, will reissue the POST request to the secondary.

Community
  • 1
  • 1
vtortola
  • 34,709
  • 29
  • 161
  • 263