I am new to elixir and did a slack bot(https://github.com/ahsandar/ultronex) few months ago and now added a simple JSON api (https://github.com/ahsandar/ultronex/tree/master/lib/ultronex/server) to it to check stats. The api has basically 5 paths
- /heartbeat
- /track
- /stats
*/ favicon - _ (match all to 404)
The slowest of all these endpoint seem to be heartbeat while both track and stats have to fetch values from ets for their JSON response while heartbeat responds with a static JSON. It would be understandable for the _ match to be the slowest because of looking for a matching path before the request is dispatched to it.
I can see the avg time for heartbeat is over 1.7ms while stats and track are below 0.7ms. These are NewRelic numbers. Even in the logs I see the heartbeat to be 5X slower compared to other endpoints. It might seem weird to be questioning times as low as 1 ms but the performance variation is of interest as it adds unpredictability.
Can’t upload images as a new member to show the numbers.
Any help in understanding why this would be happening or did I get something misconfigured as I plan to take elixir and phoenix for my next project but this is a bit boggling why such varied performance. Any help or guidance over why this happens and how to fix this would be nice
The source code can be found on these links