소스 검색

perf(webhook): evaluate replies in fresh process rather than in ehttpc

This surprisingly simple change yields a big performance improvement
in throughput.

While the previous commit achieves ~ 55 k messages / s
in throughput under some test conditions (100 k concurrent publishers
publishing 1 QoS 1 message per second), the simple change in this
commit improves it further to ~ 63 k messages / s.

Benchmarks indicated that the evaluating one reply function is
consistently quite fast (~ 20 µs), which makes this performance gain
counterintuitive.  Perhaps, although each call is cheap, `ehttpc`
calls several of these in a row when there are several sent requests,
and those costs might add up in latency.
Thales Macedo Garitezi 2 년 전
부모
커밋
bc7d0d5fd6
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      apps/emqx_connector/src/emqx_connector_http.erl

+ 1 - 1
apps/emqx_connector/src/emqx_connector_http.erl

@@ -645,7 +645,7 @@ to_bin(Atom) when is_atom(Atom) ->
     atom_to_binary(Atom, utf8).
 
 reply_delegator(Context, ReplyFunAndArgs, Result) ->
-    maybe_retry(Result, Context, ReplyFunAndArgs).
+    spawn(fun() -> maybe_retry(Result, Context, ReplyFunAndArgs) end).
 
 transform_result(Result) ->
     case Result of