How to protect the spray from overload?

I have the following explicit algorithm:

  • The client sends a request to my spray application.
  • Spray receives a request and I see the spray load when multiple requests come in.
  • If the download is high, the spray returns HTTP 503; otherwise, it will start processing the request.

How can I manage the current spray load?

Also, since I understand that the spray uses akka internally, which can be extended with additional nodes added, so how can I manage the load with additional nodes?

+3


source to share


1 answer


The spray itself uses reactive I / O and can handle very heavy loads, probably higher than any protected code it can protect. So don't worry about trying to protect your spray system. If you have complex processing logic that might take a while to process certain requests, it might make sense to put a protective choke around that processing logic using something like http://letitcrash.com/post/28901663062/throttling-messages- in-akka-2 . And in case the queue is full, you can simply complete(StatusCodes.ServiceUnavailable)

.



0


source







All Articles