简体   繁体   English

如何配置我的 elixir phoenix 服务器?

[英]How can I profile my elixir phoenix server?

I have a Phoenix server which basically proxies GraphQL into a lot of REST API backends.我有一个 Phoenix 服务器,它基本上将 GraphQL 代理到许多 REST API 后端。 It finds the username from a provided JWT, and chooses the appropriate backend.它从提供的 JWT 中找到用户名,并选择合适的后端。

Now, I benchmarked the backends to be able to handle 13K req/sec.现在,我对后端进行了基准测试,使其能够处理 13K 请求/秒。 But my GraphQL frontend can only do 400 req/sec, and in dev mode only 15 req/sec..但是我的 GraphQL 前端只能做到 400 请求/秒,而在开发模式下只能做到 15 请求/秒。

I am suspecting the JWT processing is the problem here, but how do I confirm that?我怀疑 JWT 处理是这里的问题,但我如何确认?

I tried :observer, but this output confuses me (what are 'Reductions'?)我试过:观察者,但这个输出让我感到困惑(什么是“减少”?)

观察者输出

EDIT: I was pointed to erlang tracer and fprof.编辑:我被指出 erlang tracer 和 fprof。 So I decided to try fprof.所以我决定尝试 fprof。 Found this blog post .找到了这篇博文 This is my console output, and now I'm stuck again:这是我的控制台输出,现在我又卡住了:

iex(wobble@localhost)1> :fprof.trace([start, {procs, [whereis(my_web) ]}])
** (CompileError) iex:1: undefined function start/0

iex(wobble@localhost)1> :fprof.trace([:start, {procs, [whereis(my_web) ]}])
** (CompileError) iex:1: undefined function procs/0
    (stdlib) lists.erl:1354: :lists.mapfoldl/3

iex(wobble@localhost)1> :fprof.trace([:start, {:procs, [whereis(my_web) ]}])
** (CompileError) iex:1: undefined function whereis/1
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (stdlib) lists.erl:1355: :lists.mapfoldl/3

iex(wobble@localhost)1> :fprof.trace([:start, {:procs, [:whereis(my_web) ]}])
** (SyntaxError) iex:1: syntax error before: '('

Reductions are unit of the execution in Erlang. 归约是 Erlang 中的执行单位。 You can think about it as an instruction in machine code.您可以将其视为机器代码中的一条指令。

What you want to do is to run tracer .你想要做的是运行tracer It will tell you how often are your functions called.它会告诉您函数的调用频率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM