1
votes

I've started getting slow responses for every single page in my website. I'm not sure how this came about.

Phoenix logging reports micro or milliseconds, yet the actual response time has a noticeable delay, always around half a second as reported by the browser dev tools.

In an attempt to examine the cause, I created a minimal controller:

defmodule MyApp.HelloController do
  use Phoenix.Controller
  def index(conn, _params) do
    text(conn, "Hello")
  end
end
# router
get "/hello", HelloController, :index

I also completely cleared the :browser pipeline.

The response time is the same, slow, half a second as above.

How might I determine the cause of this?

Edit: I'm using localhost:4000 on my development computer. I also did a phoenix.new helloworld fresh project – it works normally.

I notice the live reload websocket request to http://localhost:4000/phoenix/live_reload/socket/websocket?vsn=1.0.0 also has this same half-second delay too.

2
Are you testing this locally on the same computer?Yoav Glazner
Did you try running your app in production mode? This doesn't compile /web during runtime, maybe that's the issueJonas Dellinger
Thanks, but, no, I haven't touched production mode. I'm at a loss.tenuej
Would it be possible to upload a copy of the minimal project that shows this problem, especially since you cannot reproduce this with a brand new app?Dogbert
Thank you, but I can't reproduce the problem. In the end, I just systematically copied across individual parts of my code to a new project. Everything works fine. I still have no idea what happened before, but I need to move on.tenuej

2 Answers

2
votes

Okay, I think I've worked out what the problem was.

I don't use brunch, and I'd put various javascript files inside a web/static/js directory. These included the sizeable node_modules directory. I moved this js directory outside the web directory, and now everything is fast again.

It seems that Phoenix did some processing on that large web/static/js directory on each request.

Although I generally like Phoenix, I do find its directory structure confusing. I'd be grateful is someone could provide any linked references for better understanding the various folders and sub-folders so I can avoid this type of problem in future.

0
votes

Taking a shot in the dark: maybe Network Throttling was left on 3G or something slow, if you're using Chrome Dev Tools?

https://developers.google.com/web/tools/chrome-devtools/profile/network-performance/network-conditions?hl=en#emulate-network-connectivity