wlminimal

wlminimal

Hi I am using Drab for live updating page.
in commander file

defhandler show_dashboard_stats(socket, sender) do
    order_id = sender.params["campaign_id"]

    user_id = socket.assigns.current_user_id

    order = Sales.get_order_by_id(order_id, user_id)

    message_status = Messenger.get_all_message_status(order_id)

    total_sent = Enum.count(message_status)

    deilvered_count = Analytics.get_delivered_message_status_count(message_status)

    undelivered_count = Analytics.get_undelivered_message_status_count(message_status)

    bitly = Bitly.get_bitly_by_order_id(order_id)

    total_clicks = Analytics.load_clicks(bitly)

    IO.puts(" ++++++++++++ poking +++++++++++++")
    poke(socket,
      total_sent: total_sent,
      deilvered_count: deilvered_count,
      undelivered_count: undelivered_count,
      total_clicks: total_clicks
    )
   IO.puts("+++++++++++++ poking is done ++++++++++")
    socket |> exec_js!("DashboardChart.update()")
  end

In local server it tooks less than second. but in production it took more than 5 seconds.
I tried to find where is bottleneck and checked function execution time.
Longest time I measured was 1 second from Analytics.load_clicks(bitly) (this function does external api request)

I added IO.puts function before and after poke. and it took more than 5 seconds to print “poking is done”
I think “poke” is the one cause the problem.

Am I correct?
I deployed in Heroku and using Hobby dynos

Showing Posts 1 to 10

OvermindDL1

OvermindDL1

Sounds like Heroku is adding latency. Do you have a URL to your test instance so I can trace the network connection?

grych

grych

Creator of Drab

It may make sense that the latency of the network increase time from one to five seconds.

@wlminimal, can you measure how long this single poke takes in dev and prod? Just measure the time difference:

IO.puts(" ++++++++++++ poking +++++++++++++")
t0 = :os.system_time(:milli_seconds)
poke(socket,
  total_sent: total_sent,
  deilvered_count: deilvered_count,
  undelivered_count: undelivered_count,
  total_clicks: total_clicks
)
IO.puts("+++++++++++++ poking is done ++++++++++")
IO.puts("it took #{:os.system_time(:milli_seconds) - t0} ms")
wlminimal

wlminimal OP

I tried..
in dev it took 2031 ms
in prod it took 8691 ms.

wlminimal

wlminimal OP

umm. I really want to do it
But my problem is in logged in dashboard.
I don’t know the way to show you :(:sweat_smile:

OvermindDL1

OvermindDL1

What is your latency to your heroku server? Like just access a path that doesn’t exist on it and how long does it take to respond 404 from that request?

EDIT: For note, Drab works over Phoenix Channels, it would absolutely not be slow, either the work being done is slow or the network connection is slow.

wlminimal

wlminimal OP

few seconds, 1 or less

tried this https://www.texty.marketing/non-exist

grych

grych

Creator of Drab

OMG. 2 seconds on DEV? It is definitely not a problem with latency, but with the complexity of your page! Either you page renders for 2 seconds, or you have a plenty of big assigns on the page.

I suggest two solutions for this:

  • cut your page into pieces by using partials - here you can see the advantage of this approach
  • do not use Drab.Live, as it must re-render the page at every poke you do; use Drab.Element to update the page instead
OvermindDL1

OvermindDL1

I figured that would just be from the HTTP request the server makes to that other server they mentioned earlier?

grych

grych

Creator of Drab

This 2 seconds is just a poke. What poke does is:

  • get the current assign values from the browser (it can be a long operation if you have a lot of big assigns); it is cached later
  • re-render the page, which also can be a long operation if the page is big
OvermindDL1

OvermindDL1

Oh wait that’s from the server to the client with response back to server (not client to server with response back to client)? That is crazy slow then, I’ve never seen that be slow in dev! (I use a lot of shared commanders though)

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews