4

I am working on high performance web application that uses jetty and jersey for REST. I am trying to find the best way to return 503 if CPU load, memory bandwidth or pending connections are high.

Looking around the web I did not find much instructions on how to do it, and almost nothing on Jetty.

The way to do it is using proxy, filter, code in the servlet?

mbdev
  • 6,343
  • 14
  • 46
  • 63

1 Answers1

2

it pretty much depends on what OS you are. if you are on linux, then it's quite easy to add 503 based on cpu/memory - use /proc/meminfo and uptime to figure loads and act as you wish. as for pending connections, that's more tricky and solution should be looked at apache level (given that your are apache).

my 2 cents.

jancha
  • 4,916
  • 1
  • 24
  • 39
  • At what level (script/filter/code) would it be best to achieve this? if the server is busy, perhaps it would not even be able to get to the code that returns 503. – mbdev Sep 01 '11 at 07:09
  • well, if you have high loads, I would suggest setting up proper cluster. then then balancer would watch after the nodes. and in case no node is there to serve the request, it can bounce it back with proper message. also, you might want to consider nginx - it has nice and simple way of handling high load situations. – jancha Sep 01 '11 at 07:38