Phoenix deployment options and performance

Hi! I was going to post in the Phoenix category but the “New topic” button is disabled for some reason?

I’m new to Elixir and Phoenix, and so far I love what I see. I am setting up Docker for deployment and have tried both options to run the app: 1) with MIX_ENV=prod phx.server, 2) mix release deployment.

I thought that the release mode would yield better performance from what I’ve read here and there but some very simple benchmarks with tools like Apache bench it seems that mix phx.server does more req/sec. Isn’t the release supposed to be better performing?

Thanks in advance for any clarification :slight_smile:

It is only “better performing” for initial requests, so the p99s and such should be lower. But if you have any period of warmup then it won’t show up in the benchmarks.

Once all modules are loaded (a release will load all modules on boot while with mix they are only loaded when first called) the performance will be the same.

But a release gives you a smaller deploy artifact with a smaller surface area, with an easier to control boot-up and lifecycle management (or at least more “standard”).
.

3 Likes

Oh and if there are real consistent differences in the req/s I’d check if there is a difference in VM settings between the two.

Hi @tristan! I actually have the following settings in environment variables. I was wondering that perhaps these affect performance only when I run phx.server and not the release? Can you confirm? Thanks!

    ERL_COMPILER_OPTIONS="[{hipe, [o3]}]" 
    ELIXIR_ERL_OPTIONS="+K true +swt very_high +A 100" 

I don’t know if the release script checks ELIXIR_ERL_OPTIONS, should be simple to check. But you can just add those, one on each line, to vm.args.eex.

1 Like

ERL_COMPILER_OPTIONS do affect the modules bytecode, ELIXIR_ERL_OPTIONS only affect the VM started under environments that have this variable set.

So, hipe should be in the release, while you need to set the runtime flags again when running the release. As far as I know, releases have a special configuration file that is read solely to determine VM args, but I really can’t give you any details about that.