Stuff Goes Bad:Erlang In Anger

Asking For Permission

请求许可

A somewhat simpler approach to back-pressure is to identify the resources we want to block on, those that cannot be made faster and are critical to your business and users. Lock these resources behind a module or procedure where a caller must ask for the right to make a request and use them.
There’s plenty of variables that can be used: memory, CPU, overall load, a bounded number of calls, concurrency, response times, a combination of them, and so on.

 back-pressure有某些简单的方法:把那些不能变快和对你业务和用户来说至关重要的资源,都打上标识,如果一个模块或程序想调用这个资源,就必须先申请到使用此资源的权限才能使用它。
 这里有很多参考值可以作为衡量标准:内存,CPU,总负载,达到一定量的调用,并发活动,应答时间以及一系列他们的组合等等。

The SafetyValve 11 application is a system-wide framework that can be used when you know back-pressure is what you’ll need.
For more specific use cases having to do with service or system failures, there are plenty of circuit breaker applications available. Examples include breaky 12, fuse 13, or Klarna’s circuit_breaker 14.
Otherwise, ad-hoc solutions can be written using processes, ETS, or any other tool available.

 安全阈值(SafetyValve) application就是一个可以让你得到你想了解的back-pressure指标的系统级的框架。
 下面还很多关于这方面的应用,你可以找到更具体的用例与服务或系统故障,比如:breaky12, fuse13, Klarna’s14 circuit_breaker
 另外,主流的解决方案是使用进程,ETS,或其它可用的工具。

The important part is that the edge of the system (or subsystem) may block and ask for the right to process data, but the critical bottleneck in code is the one to determine whether that right can be granted or not.
The advantage of proceeding that way is that you may just avoid all the tricky stuff about timers and making every single layer of abstraction synchronous.
You’ll instead put guards at the bottleneck and at a given edge or control point, and everything in between can be expressed in the most readable way possible.

 系统边缘(the edge of the system)或子系统中重要的部分可能会阻塞并请求处理数据,但是代码中关键瓶颈在于什么情况下可以授权?
 这样(指阻塞着处理数据)处理的优势在于:你可以禁止所有棘手的时间定时器并让每一个抽象层(single layer of abstraction)都同步.
 你可以在瓶颈处设置好防护,设置好一个阈值,在此范围内的所有都可以被描述清楚。

[11] https://github.com/jlouis/safetyvalve
[12] https://github.com/mmzeeman/breaky
[13] https://github.com/jlouis/fuse
[14] https://github.com/klarna/circuit_breaker

[注11]:1https://github.com/jlouis/safetyvalve .
[注12]:2https://github.com/mmzeeman/breaky
[注13]:https://github.com/jlouis/fuse
[注14]:https://github.com/klarna/circuit_breaker