basho/riak_kv — pull request #544 by jtuple (2013-05-04 10:34:44+00:00)
Title: Bound the number of get/put FSMs to prevent overload

This pull-request implements FSM overload protection that prevents Riak from spawning an unbounded number of get/put FSMs, eventually reaching the maximum number of allowed processes and crashing.

The limit is configured by setting the `riak_kv/fsm_limit application` variable. Setting to `undefined` disables overload protection, falling back to the prior code path. This value cannot be changed at runtime, a node restart is necessary for a change to take effect.

The limiting is implemented using the [sidejob](https://github.com/basho/sidejob) library. There are two sidejob_supervisors, one for get FSMs and one for put FSMs. Each supervisor independently enforces the FSM limit, thus there can be at most (limit) get FSMs and (limit) put FSMs.

The response `{error, overload}` is returned whenever the limit is reached.

This pull-request requires the related pull-request: basho/sidejob#1