Limit concurrent queries with Spray

I use the spray function to create a simple HTTP server. This server accesses several services that require a response time (in seconds). We would like to decline requests when the number of simultaneous requests becomes large. Otherwise, a large number of simultaneous requests does not bring any benefit to the system.

There are several levels where this can be allowed. I am not sure how to do any of them for sure, or which is the best.

  • I could provide an execution context for spray routing that has a limited queue and rejection policy.

  • I could limit the mailbox size of my http-spray server, as it is also an actor.

  • I could configure the parameter in application.conf, which refers to it directly for the spray.

What is a simple, effective way to implement such a policy?

+4
source share
1 answer

I don’t know which solution would be better for your case (I would go for the creation of my own execution context), but I think that perhaps you should rethink how you want to process your requests.

What do you do with your request? Are you trying to deal with them in Spray directly? With some help from Futures?

, , . , , . . Akka , .

, , , -, - .

+1

Source: https://habr.com/ru/post/1523431/


All Articles