Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fine-tune cowboy's runtime behavior?

I'm in the process of choosing a technology for my high-throughput web server. I've created two naive implementations, one in Go and one in Elixir, using Phoenix.

I've deployed these versions on an extra large machine on AWS, and used siege to benchmark their performance.

I've managed to increase Go's performance after setting the GOMAXPROCS, but running the Elixir version seems to reach its peak performance long before it fully utilizes the machine's CPU or memory.

I couldn't seem to find any documentation or explanation on how I can fine-tune cowboy's behavior in production settings, so it will properly utilize the machine it runs on, and produce the performance everybody talks about...

I'm pretty sure that there is a simple place (file or environment variable) where I can tweak a value or two to produce much better results.

Can anyone tell me where that place may be?

like image 552
Uri Agassi Avatar asked Dec 15 '22 21:12

Uri Agassi


2 Answers

Following the suggestions in the comments, I've re-implemented my project using plug instead of phoenix.

With the same functionality (parsing post body to JSON, calling DynamoDB, reading from an Amnesia table and formatting a JSON response) I've received a much better performance, with far more resource utilization.

I guess I can still "milk" a few more requests per second (currently I get around 500 requests per second), but it is now on-par with the Go implementation of the same thing...

like image 130
Uri Agassi Avatar answered Jan 30 '23 14:01

Uri Agassi


I don't have enough rep to comment directly, so I'll answer here. I'd love to see the numbers you got with Phoenix. Were you running in prod mode? Perf will be much slower if you were running in dev (the default) since code reloading is enabled and checking on every request. Vanilla Plug is going to be doing less work than Phoenix, but not much less. A standard Phoenix Router/Controller should be more or less inline with the Plug code you end up with.

like image 24
Chris McCord Avatar answered Jan 30 '23 14:01

Chris McCord