I’m using Phoenix to build an API that takes an HTTP request (JSON) and modify some fields in it (after connecting to MongoDB), send it to another server, receive the response, modify some fields in the response and send it back to the client. I implemented the same application with NodeJS as well
I run both on Ubuntu server (and both in production mode, using PORT=4000 MIX_ENV=prod mix phx.server for phoenix).
The internet speed is low: 200 Kbps (but for both implementations)
I run tests using Apache Jmeter for both of them
Threads: 500
Ramp-up: 1
loops: 10
and get the following results
NodeJS:
Phoenix:
what really surprised me is that phoenix is as fast as NodeJS and the error rate of phoenix is higher
Hi, first of all 39,4% vs 44,6 error rate isn’t much of a difference…
figure out what you are testing - obviously you are saturating the servers - what is the bottleneck - try lowering the testing load and figure out what is going on - you mention limited bandwidth… is that the bottleneck, what is causing the errors - external api timeouts, db timeouts - request timeouts?
timeouts - this is obviously about timeouts - what does the logs say - figure out increasing the various timeouts (both node/elixir) - so you can run the load test with no errors.
code? what does the code do - how have you programmed it? is a simple controller? do you use Genservers etc - what http client is used for calling external api - is that connection kept alive etc etc
Phoenix ships with a 60 second idle_timeout - start by increasing it
most likely - could also be why you see similar/same amount of error rates on node…
so what you are testing isn’t really the node/phoenix servers - but the external api servers;-) ?
but - there are various http clients for elixir - some better than others for various scenarios - how does the external api act? is it rate limiting you? maybe you need to rate limit requests sent to external api etc. - can you keep alive the connection and reuse it? etc.
but start by increasing HTTPoison timeout (and above phoenix idle_timeout) and the http client timeout on node (and any idle timeout) - try to get no errors… then optimize…