java - Prevent client from overloading server? -


i have java servlet that's getting overloaded client requests during peak hours. clients span concurrent requests. number of requests per second great.

should implement application logic restrict number of request client can send per second? need done on application level?

the 2 common ways of handling turn away requests when server busy, or handle each request slower.

turning away requests easy; run fixed number of instances. os may or may not queue few connection requests, in general users fail connect. more graceful way of doing have service return error code indicating client should try again later.

handling requests slower bit more work, because requires separating servlet handling requests class doing work in different thread. can have larger number of servlets worker bees. when request comes in accepts it, waits worker bee, grabs , uses it, frees it, returns results.

the 2 can communicate through 1 of classes in java.util.concurrent, linkedblockingqueue or threadpoolexecutor. if want fancy, can use priorityblockingqueue serve customers before others.

me, throw more hardware @ anon said ;)


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -